Cannot use types.NewDecimal(5, 1) (value of type types.Decimal) as types.Decimal value in struct literal

Hi I am new to go and not able to decode this message. As part of error message both assigned and expected type is Decimal but still it gives error.

“cannot use types.NewDecimal(5, 1) (value of type types.Decimal) as types.Decimal value in struct literal”

Error “owner”: “generated_diagnostic_collection_name#0”, “code”: { “value”: “IncompatibleAssign”, “target”: { “$mid”: 1, “external”: “typesinternal package - golang.org/x/tools/internal/typesinternal - pkg.go.dev”, “path”: “/golang.org/x/tools/internal/typesinternal”, “scheme”: “https”, “authority”: “pkg.go.dev”, “query”: “utm_source=gopls”, “fragment”: “IncompatibleAssign” } }, “severity”: 8, “message”: “cannot use types.NewDecimal(5, 1) (value of type types.Decimal) as types.Decimal value in struct literal”, “source”: “compiler”, “startLineNumber”: 33, “startColumn”: 27, “endLineNumber”: 33, “endColumn”: 49 }]

Can you please share the offending code?

The mention of internal makes me wonder…

1 Like

Thanks @NobbZ . Able to find the root cause. Actually I have configured two path in GOPATH environment variable(path1 and path2) and package “types” is present in both the paths. Due to this in code left side of my assignment is point out to path1 and right side is point to path2. Though the packages are same in terms of code go still errors out.
Once I removed the package from path2 it woks fine :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.