Skip to content

Commit

Permalink
change yaml decoder to fix nested field problem
Browse files Browse the repository at this point in the history
もし、ScriptConfig.Data/ScriptConfig.Dataにネストしたデータ構造が
存在した場合、gopkg.in/yaml.v2ではmap[interface{}]interface{}型の
データとして格納される。
しかし、jsonではkeyは必ずstringである必要があるため、jsonに変換する
過程でこのようなエラーが発生する。

panic: json: unsupported type: map[interface {}]interface {}

map[string]interface{}型を返すよう、パッチを当てた実装に切り替える
ことで、この問題を回避する。
  • Loading branch information
yuuki0xff committed May 19, 2019
1 parent 1d95397 commit ad8847c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"
"github.com/yuuki0xff/clustertest/models"
"gopkg.in/yaml.v2"
"github.com/yuuki0xff/yaml"
)

type Config struct {
Expand Down

0 comments on commit ad8847c

Please sign in to comment.