N
N
Nikolay Baranenko2019-04-24 21:14:36
go
Nikolay Baranenko, 2019-04-24 21:14:36

Why do projects call the subfolder Vendor if go build looks for pkg in src?

Hello.
let's say there is a project on golang
nginx-prometheus-exporter
external unique pkg is placed in the vendor subfolder
if you go to build a go project
let 's say

go build -i -o /tmp/___go_build_haproxy_exporter_go /home/drno/IdeaProjects/prometheus_node_exporter/exporter.go

then before that you will have to redefine the global GOPATH variable
to your own
GOPATH="/home/drno/IdeaProjects/nginx-prometheus-exporter"

, where the builder will look for missing external libraries by adding SRC to it,
$GOPATH/src
why call vendor? why not src?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2019-04-25
@ghostiam

You do not have a correct understanding of the value of the vendor directory.
No need to redefine gopath, go looks for dependencies not only in gopath but also in the vendor directory at the root of the project. This is used to freeze current dependencies.
https://blog.gopheracademy.com/advent-2015/vendor-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question