Golang packaging: Difference between revisions

From wikinotes
No edit summary
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Documentation =
How to install executables,<br>
<blockquote>
manage project requirements,<br>
{| class="wikitable"
and publish your project to the go index (or create a private module).
|-
| private modules || https://go.dev/ref/mod#private-modules
|-
| module proxies || https://go.dev/ref/mod#module-proxy
|-
| module cache || https://go.dev/ref/mod#module-cache
|-
|}
</blockquote><!-- Documentation -->


= Locations =
= Locations =
Line 21: Line 12:
</blockquote><!-- Locations -->
</blockquote><!-- Locations -->


= Os Packages =
 
= OS Package Management =
<blockquote>
<blockquote>
== Install Executable ==
Installing Packages
<blockquote>
<syntaxhighlight lang="bash">
Starting in golang-1.18, <code>go install</code> is used to install executables.
# golang < 1.18
go get -u example.com/x/foo


<syntaxhighlight lang="go">
# golang >= 1.18
go install github.com/appliedgocode/goman@latest # install latest goman executable
go install example.com/x/foo@latest
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Install Executable -->


== Public Packages ==
Uninstalling Packages
<blockquote>
<syntaxhighlight lang="bash">
 
# there doesn't seem to be a managed way of doing this
</blockquote><!-- Public Packages -->
rm ${GOBIN:=~/go/bin}/tool-to-delete
 
</syntaxhighlight>
== Private Packages ==
</blockquote><!-- OS Package Management -->
<blockquote>
Go executables are installed/built from src.<br>
You'll need to add your package to <code>$GOPRIVATE</code> envvar to stop it from being indexed.
 
 
</blockquote><!-- Private Packages -->
</blockquote><!-- Os Packages -->
 
= Project Requirements =
<blockquote>
== Module Requirements ==
<blockquote>
See [[go.mod file]] .
</blockquote><!-- Module Requirements -->


== Vendoring ==
= Creating/Hosting Packages =
<blockquote>
<blockquote>
In order to hosting packages for OS-install, you simply need to expose the src using the module path.<br>
It will be compiled for the platform automatically.


</blockquote><!-- Vendoring -->
* See [[golang modules]] for creating modules, managing their requirements, and publishing to the public package index
* See [[golang module path]] for instructions on private package hosting
</blockquote><!-- Project Requirements -->
</blockquote><!-- Project Requirements -->

Latest revision as of 03:52, 20 June 2022

How to install executables,
manage project requirements,
and publish your project to the go index (or create a private module).

Locations

~/go/bin default $GOBIN path, where go executables are installed


OS Package Management

Installing Packages

# golang < 1.18
go get -u example.com/x/foo

# golang >= 1.18
go install example.com/x/foo@latest

Uninstalling Packages

# there doesn't seem to be a managed way of doing this
rm ${GOBIN:=~/go/bin}/tool-to-delete

Creating/Hosting Packages

In order to hosting packages for OS-install, you simply need to expose the src using the module path.
It will be compiled for the platform automatically.

  • See golang modules for creating modules, managing their requirements, and publishing to the public package index
  • See golang module path for instructions on private package hosting