// config.go
package config
import "flag"
func CreateConfig() (ConfigStruct, error) {
configPath := flag.String("config", defaultConfig, "config file path")
...
}
// config_test.go
package config_test
import "my/path/config"
func TestCreateConfig() {
config.CreateConfig()
...
}
/tmp/go-build887413297/mypath/config/_test/config.test flag redefined: custom_config
/usr/local/go/src/runtime/panic.go:387
// config.go
package config
import "flag"
val configPath *string
func init() {
configPath := flag.String("config", "", "config file path")
}
func CreateConfig() (ConfigStruct, error) {
flag.Parse()
use(*configPath)
...
}
// config_test.go
package config_test
import "my/path/config"
func TestCreateConfig() {
config.CreateConfig()
...
}
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.