Похожие чаты

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 ответов

2 просмотра

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.

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

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

Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
Hey, Oceaners 🌊 As we approach Phase 1 of the token merger, OCEAN and AGIX will migrate to FET starting July 1st! Here's a list of exchanges that have communicated their su...
KreigDK | Never DM first🌊
3
База данных не поможет. Шифрование не поможет. Какие там ещё варианты? Накидывайте.
КТ315
20
I love the passion, really do. I do think this is being blown way out of proportion. We are not deleting our Telegram or not allowing you to talk about anything you want, a...
Mike Herron
3
Did you guys see the latest tweet from TonGifts? 🚀
Mike
44
А как лучше конвертировать физический адрес в виртуальный при маппинге? В случае ядра у меня, например, direct mapping, первые 768МБ я как есть мапплю в higher half, а остальн...
Evg Resh
26
А табстоп это сообщение от окна или от элемента управления?
The Bird of Hermes
18
Hey, what is the best and maintained way of transpiling cpp to c? (As a need to support many different toolchains quickly and may not have a c++ support in the given toolch...
Meitar Reihan
11
Открыл свой двухкилобайтный экзешник в x32dbg, а тут какая-то хрень. Смущает кнопка "выполнить до пользовательского кода", а что ещё может быть в файле помимо него ?
НѣкъиⰘижєжєиꙁъвьсєсвѣтьноѣсѣтиѥсть•
11
Hey guys, did you see the latest announcement about $FUN? 🔥
Brian
21
Карта сайта