diff --git a/Changelog.md b/Changelog.md index 108118b7be..143b56365d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ ## Unreleased +- golang: Updates go.mod parser to be compatible with golang v1.21. ([#1304](https://github.com/fossas/fossa-cli/pull/1304)) - `fossa list-targets`: list-target command supports `--format` option with: `ndjson`, `text`, and `legacy`. ([#1296](https://github.com/fossas/fossa-cli/pull/1296)) ## v3.8.17 diff --git a/src/Strategy/Go/Gomod.hs b/src/Strategy/Go/Gomod.hs index de9781e3dd..15570ee9c7 100644 --- a/src/Strategy/Go/Gomod.hs +++ b/src/Strategy/Go/Gomod.hs @@ -82,6 +82,10 @@ data Statement -- of go.mod, refer to: https://go.dev/ref/mod#go-mod-file-retract RetractStatement | GoVersionStatement Text + | -- | we do not care about values associated with + -- the toolchain block as they are of no use to us today. + -- Refer to: https://go.dev/doc/modules/gomod-ref#toolchain + ToolchainStatement Text deriving (Eq, Ord, Show) type PackageName = Text @@ -218,6 +222,7 @@ gomodParser = do where statement = (singleton <$> goVersionStatement) -- singleton wraps the Parser Statement into a Parser [Statement] + <|> (singleton <$> toolChainStatements) <|> requireStatements <|> replaceStatements <|> excludeStatements @@ -228,6 +233,11 @@ gomodParser = do goVersionStatement :: Parser Statement goVersionStatement = GoVersionStatement <$ lexeme (chunk "go") <*> goVersion + -- top-level go version statement + -- e.g., toolchain go1.21.1 + toolChainStatements :: Parser Statement + toolChainStatements = ToolchainStatement <$ lexeme (chunk "toolchain") <*> anyToken + -- top-level require statements -- e.g.: -- require golang.org/x/text v1.0.0 diff --git a/test/Go/testdata/go.mod.edgecases b/test/Go/testdata/go.mod.edgecases index 391898ffab..af19ead67d 100644 --- a/test/Go/testdata/go.mod.edgecases +++ b/test/Go/testdata/go.mod.edgecases @@ -5,6 +5,8 @@ module test/package go 1.12 +toolchain go1.21.1 + require repo/name/A v1.0.0 // indirect require (