rename ConfigConfigure.Check to ConfigConfigure.Validate
update sample in README.md
This commit is contained in:
@@ -10,6 +10,9 @@ go get gitea.v39.writerpass.top/Public/json-configure-golang
|
||||
package main
|
||||
|
||||
import "log"
|
||||
import "os"
|
||||
import "gitea.v39.writerpass.top/Public/json-configure-golang/config"
|
||||
|
||||
|
||||
type AppConfig struct {
|
||||
AppName string `json:"app_name"`
|
||||
@@ -17,12 +20,14 @@ type AppConfig struct {
|
||||
}
|
||||
|
||||
func main() {
|
||||
os.Setenv("DEBUG", "true")
|
||||
|
||||
configure := AppConfig{
|
||||
AppName: "aaaaa",
|
||||
}
|
||||
cc := ConfigConfigure{
|
||||
cc := config.ConfigConfigure{
|
||||
AppName: "json-configure",
|
||||
ContainerType: BesidesExe,
|
||||
ContainerType: config.BesidesExe,
|
||||
ConfigureFile: "config.json",
|
||||
}
|
||||
cc.Check()
|
||||
|
@@ -15,19 +15,21 @@ type ConfigConfigure struct {
|
||||
ConfigureFile string
|
||||
}
|
||||
|
||||
func (receiver *ConfigConfigure) Check() {
|
||||
func (receiver *ConfigConfigure) Validate() {
|
||||
if receiver.ContainerType == None {
|
||||
log.Fatal("Check, ContainerType should not be None or Empty ")
|
||||
log.Fatal("Validate, ContainerType should not be None or Empty")
|
||||
} else if receiver.ContainerType == BesidesExe {
|
||||
// pass
|
||||
} else if receiver.ContainerType == UserConfig {
|
||||
if receiver.AppName == "" {
|
||||
log.Fatal("Check, AppName should not be None while ContainerType == UserConfig")
|
||||
log.Fatal("Validate, AppName should not be None while ContainerType == UserConfig")
|
||||
}
|
||||
} else if receiver.ContainerType == SystemConfig {
|
||||
if receiver.AppName == "" {
|
||||
log.Fatal("Check, AppName should not be None while ContainerType == SystemConfig\nBesides SystemConfig is not supported for now")
|
||||
log.Fatal("Validate, AppName should not be None while ContainerType == SystemConfig\nBesides SystemConfig is not supported for now")
|
||||
}
|
||||
} else {
|
||||
log.Fatalf("Validate, ContainerType should not be %s \n", receiver.ContainerType)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user