Skip to content

Commit

Permalink
fix: strict yaml decoding with KnownFields
Browse files Browse the repository at this point in the history
Error on unknown fields.
  • Loading branch information
gszr committed Jul 22, 2023
1 parent 884584e commit 4ecc701
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@ func readDotFile(file string) Dots {
}

var dots Dots
if err := yaml.Unmarshal([]byte(rcFileData), &dots); err != nil {

decoder := yaml.NewDecoder(bytes.NewReader(rcFileData))
decoder.KnownFields(true)

if err := decoder.Decode(&dots); err != nil {
logger.Fatalf("cannot decode data: %v", err)
}

Expand Down

0 comments on commit 4ecc701

Please sign in to comment.