1
resposta

Erro importação de módulo

Erro: no required module provides package github.com/lib/pq: go.mod file not found in current directory or any parent directory; see 'go help modules'

Como solução executei os seguintes comandos:

go get github.com/lib/pq

go env GOPATH

go mod init

Log da operação e erro para que possam entender o que ocorreu e como fiz para corrigir. PS C:\Users\jonathan.jsilva\go\src\github.com\JhonJeff> go run main.go main.go:8:2: no required module provides package github.com/lib/pq: go.mod file not found in current directory or any parent directory; see 'go he

PS C:\Users\jonathan.jsilva\go\src\github.com\JhonJeff> go get github.com/lib/pq

PS C:\Users\jonathan.jsilva\go\src\github.com\JhonJeff> go env GOPATH

PS C:\Users\jonathan.jsilva\go\src\github.com\JhonJeff> go run main.go lp modules'

PS C:\Users\jonathan.jsilva\go\src\github.com\JhonJeff> go mod init go: creating new go.mod: module github.com/JhonJeff go: to add module requirements and sums: go mod tidy

PS C:\Users\jonathan.jsilva\go\src\github.com\JhonJeff> go run main.go main.go:8:2: no required module provides package github.com/lib/pq; to add it: go get github.com/lib/pq

PS C:\Users\jonathan.jsilva\go\src\github.com\JhonJeff> go get github.com/lib/pq go get: added github.com/lib/pq v1.10.2

PS C:\Users\jonathan.jsilva\go\src\github.com\JhonJeff> go run main.go

1 resposta

Oi Jonathan

Obrigado por compartilhar a solução