Hi every one again. How to create my own a local package into my project, and how to call it?
It’s a simple walkthrough for creating your own library.
A local package is the same as a package downloaded from a public VCS repository (like github, bitbucket, etc.). It only does not have any VCS underneath.
In particular, you use the same naming conventions, and the path used in the
import directive also starts at
import "mycode/mylib" imports the package
However, if you intend to publish your code on GitHub, Bitbucket, Gitlab or elsewhere at some point in the future, you should use the respective import path from the beginning. This saves you from having to rewrite your import paths when you move your pacakge to a
go get-able location.
Note that you don’t need to set up, say, a Github repository in order to create a local package at
$GOPATH/src/github.com/<yourusername>/<yourpackage>. The path, even when named like this, is a local repo until you decide to add a git repo there and sync it to Github.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.