Home > OS >  Issue in installing a go package
Issue in installing a go package

Time:06-15

So,I recently started following a video tutorial and i am fairly new to golang and tried installing the forked version of bolt db using $ go get go.etcd.io/bbolt/... Note : I want to use this specific version but i am getting an error which says

go: go.mod file not found in current directory or any parent directory.
        'go get' is no longer supported outside a module.
        To build and install a command, use 'go install' with a version,
        like 'go install example.com/cmd@latest'
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install' 

I read a few GitHub issues which say that go get is deprecated so how do I resolve this ? I also tried few other things such as go install go.etcd.io/bbolt/...

CodePudding user response:

Go modules are today's standard. Especially if you are new to Go; do not spend time on material that do not use (and teach) them.

Run go mod init yourproject in your project repository root directory. This will create go.mod file.

Once you have that you can either:

  • import go.etcd.io/bbolt in source code and then run go mod tidy. Go tool will find and add module to your dependencies (go.mod file). This is described in Getting started tutorial.
  • run go get go.etcd.io/bbolt directly, that will update dependencies too.

Using Go Modules series explains workflow in detail and will be helpful when converting commands from an outdated material.

  •  Tags:  
  • go
  • Related