Похожие чаты

Guys, could you suggest me an easy explanation of Golang

packages ecosystem? I've watched official google dev channel video about it, it's cool, but too ideal and simple example. In the real world i've faced much worse projects.
So, more specific questions:
- What is Go package (binary or/and source)?
- What is "main" Go package manager? (like npm in js)
- Why do we have such paths of packages "***/githubrepopath/**"? I understand, that it's not obligatory, but why i got such structure in the hello world example?
- dependency resolving
- package structure

Thanks a lot. It seems "easy", but i keep getting that feel i don't get what the hell is going on and how i can handle it easily.

2 ответов

15 просмотров

1) bin is the place where binaries are put ($GOPATH/bin is in your env variable as well). Src is the place where your source code is located (the same for all the dependencies) 2) go get, but other ones are being made as well like godep 3) go get uses git repositories and it’s just a path from $GOPATH/src (or a vendor folder). When getting a dependency the location will be: gitserver/username/projectname

There is no "main" package manager in go. There are 2 official package managers, vgo and dep. vgo is nicer and it'll remove the need for GOPATH. Then there is also go mod, I have no idea when it was built but it's pretty cool. https://dave.cheney.net/2018/07/14/taking-go-modules-for-a-spin As for, Dependency resolution, The compiler frontend first checks the dependency in $GOROOT and then in $GOPATH. GOROOT is where the compiler installed all its files, And GOPATH is set by the user. You can set it to a different directory for each project or you can just use one common GOPATH for everything. The structure of GOPATH is this, /(GOPATH) - -> pkg -- -> src - - > bin pkg folder contains compiled libraries that help in quickly compiling a project. bin contains executables. A lot of people add $GOPATH/bin to their $PATH. So, lets say if you have a project in $GOPATH/src/xyz, You can go in this directory, Run go install which will create an executable and put it in $GOPATH/bin. Since, $GOPATH/bin was in $PATH, You can use the command xyz anywhere you like. src folder contains the source code of all the libs you have downloaded. As for why the import paths contain, github.com/blablabla, I guess, go get tool was designed to pull the dependecy and put it in $GOPATH/src but there might be a situation when you have two different projects with the same name and that wouldn't work, So they changed it to create subdirectories. Go doesn't supports relative import paths, So, You need to use absolute import paths but the root is at $GOPATH/src. So, To import a package, You only need to write import github.com/xyz/abc instead of the complete absolute path to folder abc on your machine.

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта