matterbridge/vendor/github.com/spf13/viper/TROUBLESHOOTING.md
2021-06-16 21:00:49 +02:00

1.4 KiB
Raw Blame History

Troubleshooting

Unmarshaling doesnt work

The most common reason for this issue is improper use of struct tags (eg. yaml or json). Viper uses github.com/mitchellh/mapstructure under the hood for unmarshaling values which uses mapstructure tags by default. Please refer to the librarys documentation for using other struct tags.

Cannot find package

Viper installation seems to fail a lot lately with the following (or a similar) error:

cannot find package "github.com/hashicorp/hcl/tree/hcl1" in any of:
/usr/local/Cellar/go/1.15.7_1/libexec/src/github.com/hashicorp/hcl/tree/hcl1 (from $GOROOT)
/Users/user/go/src/github.com/hashicorp/hcl/tree/hcl1 (from $GOPATH)

As the error message suggests, Go tries to look up dependencies in GOPATH mode (as its commonly called) from the GOPATH. Viper opted to use Go Modules to manage its dependencies. While in many cases the two methods are interchangeable, once a dependency releases new (major) versions, GOPATH mode is no longer able to decide which version to use, so itll either use one thats already present or pick a version (usually the master branch).

The solution is easy: switch to using Go Modules. Please refer to the wiki on how to do that.

**tl;dr* export GO111MODULE=on