Fix: format flag not working (#410)

This commit is contained in:
秋のかえで 2021-03-21 17:13:51 +08:00 committed by GitHub
parent 4e63c22197
commit b0e7ad9663
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 5 deletions

View file

@ -84,10 +84,19 @@ func LoadConfig(formatName string, input interface{}) (*Config, error) {
formats := make([]string, len(v))
hasProtobuf := false
for i, file := range v {
f := getFormat(file)
var f string
if formatName == "auto" {
f = getFormat(file)
if f == "" {
return nil, newError("Unable to get format of", formatName).AtWarning()
}
}
if f == "" {
f = formatName
}
if f == "protobuf" {
hasProtobuf = true
}