Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/naftalimurgor/greetings
- Owner: naftalimurgor
- Created: 2024-01-18T15:19:45.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-01-22T13:01:33.000Z (10 months ago)
- Last Synced: 2024-06-21T19:55:53.576Z (5 months ago)
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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!