Go package import cant be found


I’m new to Go and trying to import the jwx package found here. Using the following sample code. On Windows, I execute the following command in the root of my source.

 go get github.com/lestrrat-go/jwx 
 go get github.com/lestrrat-go/jwx/jwk

The command "get go" passes:

enter image description here

but when I go into the import section of the go file I get the following error:

Any ideas?


Have a look at a fresh full working session below, hope it can help you find what it’s wrong with your procedure.

  1. Make sure we are using a recent Go version
$ go version
go version go1.18.1 linux/amd64
  1. Make sure that GOPATH is unset
$ echo $GOPATH

  1. Create and initialize a new module
$ mkdir /tmp/example
$ cd /tmp/example
$ go mod init example.com/example
go: creating new go.mod: module example.com/example
  1. Write the test program
$ cat > main.go
package main

import (


func main() {
  1. Download required modules
$ go mod tidy
go: downloading github.com/lestrrat-go/jwx/v2 v2.0.0
go: downloading github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1
go: downloading github.com/lestrrat-go/blackmagic v1.0.1
go: downloading github.com/lestrrat-go/httprc v1.0.1
go: downloading github.com/lestrrat-go/iter v1.0.2
go: downloading github.com/lestrrat-go/option v1.0.0
go: downloading github.com/goccy/go-json v0.9.7
go: downloading golang.org/x/crypto v0.0.0-20220214200702-86341886e292
go: downloading github.com/lestrrat-go/httpcc v1.0.1
go: downloading github.com/stretchr/testify v1.7.1
go: downloading gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
go: downloading github.com/davecgh/go-spew v1.1.0
go: downloading github.com/pmezard/go-difflib v1.0.0
  1. Run the test program
$ go run example.com/example

Answered By – Everton

Answer Checked By – Mildred Charles (GoLangFix Admin)

Leave a Reply

Your email address will not be published.