disable viper config for now

This commit is contained in:
c9s 2020-10-26 13:56:48 +08:00
parent 332ca7ffe8
commit 3aa40f3aab
2 changed files with 11 additions and 4 deletions

View File

@ -53,6 +53,7 @@ func Execute() {
viper.AutomaticEnv() viper.AutomaticEnv()
// setup the config paths for looking up the config file // setup the config paths for looking up the config file
/*
viper.AddConfigPath("config") viper.AddConfigPath("config")
viper.AddConfigPath("$HOME/.bbgo") viper.AddConfigPath("$HOME/.bbgo")
viper.AddConfigPath("/etc/bbgo") viper.AddConfigPath("/etc/bbgo")
@ -65,6 +66,7 @@ func Execute() {
if err != nil { if err != nil {
log.WithError(err).Fatal("failed to load config file") log.WithError(err).Fatal("failed to load config file")
} }
*/
// Once the flags are defined, we can bind config keys with flags. // Once the flags are defined, we can bind config keys with flags.
if err := viper.BindPFlags(RootCmd.PersistentFlags()); err != nil { if err := viper.BindPFlags(RootCmd.PersistentFlags()); err != nil {

View File

@ -204,22 +204,27 @@ func build(ctx context.Context, buildDir string, userConfig *config.Config, goOS
return "", err return "", err
} }
buildEnvs := []string{"GOOS=" + goOS, "GOARCH=" + goArch} buildEnvs := []string{
"GOOS=" + goOS,
"GOARCH=" + goArch,
}
buildTarget := filepath.Join(cwd, buildDir) buildTarget := filepath.Join(cwd, buildDir)
log.Infof("building binary from %s...", buildTarget)
binary := fmt.Sprintf("bbgow-%s-%s", goOS, goArch) binary := fmt.Sprintf("bbgow-%s-%s", goOS, goArch)
if output != nil { if output != nil && len(*output) > 0 {
binary = *output binary = *output
} }
log.Infof("building binary %s from %s...", binary, buildTarget)
buildCmd := exec.CommandContext(ctx, "go", "build", "-tags", "wrapper", "-o", binary, buildTarget) buildCmd := exec.CommandContext(ctx, "go", "build", "-tags", "wrapper", "-o", binary, buildTarget)
buildCmd.Env = append(os.Environ(), buildEnvs...) buildCmd.Env = append(os.Environ(), buildEnvs...)
buildCmd.Stdout = os.Stdout buildCmd.Stdout = os.Stdout
buildCmd.Stderr = os.Stderr buildCmd.Stderr = os.Stderr
if err := buildCmd.Run(); err != nil { if err := buildCmd.Run(); err != nil {
return "", err return binary, err
} }
return binary, nil return binary, nil