https://github.com/swiftsoftwaregroup/cli-go
Template for Command Line Interface (CLI) tool in Go
https://github.com/swiftsoftwaregroup/cli-go
cli cli-app go golang template-project
Last synced: 4 months ago
JSON representation
Template for Command Line Interface (CLI) tool in Go
- Host: GitHub
- URL: https://github.com/swiftsoftwaregroup/cli-go
- Owner: swiftsoftwaregroup
- License: apache-2.0
- Created: 2024-07-05T06:28:19.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-05T19:34:16.000Z (about 2 years ago)
- Last Synced: 2025-03-01T15:14:55.582Z (over 1 year ago)
- Topics: cli, cli-app, go, golang, template-project
- Language: Go
- Homepage:
- Size: 2.49 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cli-go
Template for Command Line Interface (CLI) tool in Go
## Development
### Setup for macOS
Install `goenv`:
```bash
brew install goenv
```
Install Go:
```bash
# install go 1.22.5
goenv install 1.22.5
# to install latest Go version
goenv install latest
```
### Work on macOS
Configure project:
```bash
source configure.sh
```
Open the project in Visual Studio Code:
```bash
code .
```
### Build
```bash
go build ./...
```
### Run
```bash
echo "John" > name.txt
./cli-go greet name.txt
./cli-go greet --language es name.txt
./cli-go greet -l bg name.txt
```
Output:
```bash
Hello, John!
Hola, John!
Здравей, John!
```
### Test
```bash
go test -v
```
### Generate Docs
```bash
godoc
```
Browse docs:
```bash
# this package
open http://localhost:6060/pkg/github.com/swiftsoftwaregroup/cli-go
# all packages
open http://localhost:6060/pkg/
```
### How to create a new project
```bash
# create module
go mod init github.com//cli-go
# add packages
# see: https://cobra.dev
go get github.com/spf13/cobra
touch main.go
```
Tools:
```bash
go install golang.org/x/tools/cmd/godoc@latest
```