From 6c936e2fd3c5f4e083fb984510dada61c619d248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E3=81=AE=E3=81=8B=E3=81=88=E3=81=A7?= Date: Sun, 28 Mar 2021 23:45:13 +0800 Subject: [PATCH] fix: set json to default format to stdin (#446) --- core/config.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/config.go b/core/config.go index 11199bff..c5318558 100644 --- a/core/config.go +++ b/core/config.go @@ -80,21 +80,23 @@ func getFormat(filename string) string { func LoadConfig(formatName string, input interface{}) (*Config, error) { switch v := input.(type) { case cmdarg.Arg: - formats := make([]string, len(v)) hasProtobuf := false for i, file := range v { var f string if formatName == "auto" { - f = getFormat(file) - if f == "" { - return nil, newError("Unable to get format of", formatName).AtWarning() + if file != "stdin:" { + f = getFormat(file) + } else { + f = "json" } + } else { + f = formatName } if f == "" { - f = formatName + return nil, newError("Failed to get format of ", file).AtWarning() } if f == "protobuf" {