D
D
di2019-04-21 18:12:18
go
di, 2019-04-21 18:12:18

How to include libraries through glide?

In the ~/go folder, I created the main.go script. There's the following import

import (
  "encoding/json"
  "database/sql"
  "net/http"

  _ "github.com/lib/pq"
)

go version go1.10.4 linux/amd64
Installed glide dependency manager.
glide version 0.13.1-3
Created glide.yaml file
package: github.com/Delgus/go-example
import:
  - package: github.com/lib/pq

Then I run glide up and for some reason it creates a vendor folder and stuffs all the dependencies into it. But the main.go script is completely unaware that something needs to be imported from there. Moreover, there is no src or pkg folder. Something I don’t understand at all how to work with glide
Naturally, when I run go run main.go I get
main.go:8:2: cannot find package "github.com/lib/pq" in any of:
/usr/lib/go- 1.10/src/github.com/lib/pq (from $GOROOT)
/home/alexey/go/src/github.com/lib/pq (from $GOPATH)
Sorry for the stupid question, but Riley don't understand how to use it and can't find any examples.
I found the following description in the repository
https://github.com/Masterminds/glide

The dependencies are exported to the vendor/ directory where the go tools can find and use them.
Dependencies are exported to the vendor/ directory, where the go tools can find and use them.

So how are go tools supposed to find packages?
Please understand and forgive, it is the glide package manager that is of interest, as it is used by the company, the proposal of another package manager will not be an answer to the question.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pavlyuk, 2019-04-21
@pav5000

Forget about glide and forget about 1.10, go1.12 has been around for a long time and the regular dependency manager built into it, which is better to use instead of any remnants of the past type of glide.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question