Skip to content

Commit

Permalink
Merge pull request #243 from golanglemonade/yaml-v3
Browse files Browse the repository at this point in the history
upgrade gopkg.in/yaml.v2 -> v3
  • Loading branch information
Yamashou authored Nov 21, 2024
2 parents 4f39298 + ff8698e commit 4a0fc2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 7 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"bytes"
"context"
"fmt"
"net/http"
Expand All @@ -15,7 +16,7 @@ import (
"github.com/vektah/gqlparser/v2"
"github.com/vektah/gqlparser/v2/ast"
"github.com/vektah/gqlparser/v2/validator"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
)

// Config extends the gqlgen basic config
Expand Down Expand Up @@ -125,7 +126,11 @@ func LoadConfig(filename string) (*Config, error) {
}

confContent := []byte(os.ExpandEnv(string(b)))
if err := yaml.UnmarshalStrict(confContent, &cfg); err != nil {

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

if err := decoder.Decode(&cfg); err != nil {
return nil, fmt.Errorf("unable to parse config: %w", err)
}

Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/urfave/cli/v2 v2.27.4
github.com/vektah/gqlparser/v2 v2.5.16
golang.org/x/text v0.18.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand All @@ -26,5 +26,4 @@ require (
golang.org/x/mod v0.20.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/tools v0.24.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

0 comments on commit 4a0fc2f

Please sign in to comment.