Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/naftalimurgor/greetings

an example shared go package
https://github.com/naftalimurgor/greetings

Last synced: 26 days ago
JSON representation

an example shared go package

Awesome Lists containing this project

README

        

## Shared Go package
1. mkdir `greetings`
2. cd `/greetings`
3. Run:
```sh
go mod init github.com/greetings # should match github repo for the package
```
4. Add package code and push

## Using the package in another codebase/package:

```go
import (
"github.com/naftalimurgor.com/greetings"
"fmt"
)

func main() {
msg := greetings.Hello("Ruth")
fmt.Println(msg)
}
```

## Setup with Git- has to have a package version and or release
```sh
git tag --version
git push origin v0.1.0 # can be any version number, see https://go.dev/blog/publishing-go-modules
```

That's how you publish go modules for reuse on other projects!