Skip to content

Commit 0cc107b

Browse files
authored
Update README.md (#1)
New FAQ section: - Why Mage instead of Make - Why nothing for GoLand - Why GitHub Actions, not any other CI server
1 parent d6e014b commit 0cc107b

File tree

2 files changed

+82
-13
lines changed

2 files changed

+82
-13
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Go
1+
# go
22
FROM golang:1.14.2
33
# mage
44
RUN GO111MODULE=on go get github.com/magefile/[email protected]

README.md

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1+
# Go Library Template
2+
13
[![Build Status](https://github.com/golang-templates/library/workflows/build/badge.svg)](https://github.com/golang-templates/library/actions?query=workflow%3Abuild)
24
[![GoDoc](https://godoc.org/github.com/golang-templates/library?status.svg)](https://godoc.org/github.com/golang-templates/library)
35
[![GitHub Release](https://img.shields.io/github/release/golang-templates/library.svg)](https://github.com/golang-templates/library/releases)
46
[![Go Report Card](https://goreportcard.com/badge/github.com/golang-templates/library)](https://goreportcard.com/report/github.com/golang-templates/library)
57

6-
# Go Library Template
7-
88
This is GitHub project template for a Go library. It has been created for ease-of-use for anyone who wants to:
99

1010
- quickly get into Go without losing too much time on environment setup,
1111
- create a new repoisitory with basic Continous Integration,
12-
- write Go code on Linux, MacOS, Windows,
13-
- use free tools.
12+
- write Go code on Linux, MacOS, Windows.
1413

1514
It includes:
1615

17-
- editor config: [Visual Studio Code](https://code.visualstudio.com) with [Go](https://code.visualstudio.com/docs/languages/go) and [Remote Container](https://code.visualstudio.com/docs/remote/containers) support,
18-
- dependency management: [Go Modules](https://github.com/golang/go/wiki/Modules),
19-
- linter: [GolangCI-Lint](https://github.com/golangci/golangci-lint),
20-
- build automation: [Mage](https://magefile.org), [Docker](https://docs.docker.com/engine), [Docker Compose](https://docs.docker.com/compose), [GitHub Actions](https://github.com/features/actions).
16+
- [Visual Studio Code](https://code.visualstudio.com) configuration with [Go](https://code.visualstudio.com/docs/languages/go) and [Remote Container](https://code.visualstudio.com/docs/remote/containers) support,
17+
- dependency management using [Go Modules](https://github.com/golang/go/wiki/Modules),
18+
- linting with [GolangCI-Lint](https://github.com/golangci/golangci-lint),
19+
- build automation via [Mage](https://magefile.org), [Docker](https://docs.docker.com/engine), [Docker Compose](https://docs.docker.com/compose), [GitHub Actions](https://github.com/features/actions).
2120

2221
`Star` this project if you find it valuable and worth maintaining.
2322

@@ -29,10 +28,10 @@ It includes:
2928

3029
### Setup Development Environment
3130

32-
Take notice that this project is build in a way that gives the developer a lot of freedom on the development environment setup. Below you can find proposals when using Visual Studio Code.
31+
Take notice that this project is build in a way that gives developers a lot of freedom on development environments setup. Below you can find proposals when using Visual Studio Code.
3332

34-
- **Bare metal:** Install Go, Visual Studio Code, Mage and GolangCI-Lint (see [Dockerfile](Dockerfile) for Mage and GolangCI-Lint installation commands).
35-
- **Containers:** Install Docker, Visual Studio Code with Remote - Container extension. [Instructions](https://code.visualstudio.com/docs/remote/containers).
33+
- **Bare metal:** See [Dockerfile](Dockerfile) for Mage and GolangCI-Lint installation commands.
34+
- **Containers:** [Instructions](https://code.visualstudio.com/docs/remote/containers).
3635
- **Remote via SSH**: [Instructions](https://code.visualstudio.com/docs/remote/ssh).
3736

3837
### Build
@@ -46,7 +45,77 @@ Take notice that this project is build in a way that gives the developer a lot o
4645
1. `Watch` this project to get notified about new releases, issues, etc.
4746
1. Update Go, Mage and GolangCI-Lint version in [Dockerfile](Dockerfile). Take notice that when working on bare metal or via SSH, then you should also to do it manually on your machine.
4847
1. Configure linters via [.golangci.yml](.golangci.yml).
49-
1. Develop tasks/targets in [magefile.go](magefile.go) and [.vscode/tasks.json](.vscode/tasks.json).
48+
1. Develop Mage targets in [magefile.go](magefile.go) and assosiated tasks in [.vscode/tasks.json](.vscode/tasks.json).
49+
50+
Notable files:
51+
52+
- [devcontainer.json](.devcontainer/devcontainer.json) - Visual Studio Code Remote Container configuration
53+
- [.github](.github/workflows/build.yml) - GitHub Action workflow (CI build)
54+
- [.vscode](.vscode) - Visual Studio Code configuration files
55+
- [.golangci.yml](.golangci.yml) - GolangCI-Lint configuration
56+
- [docker-compose.yml](docker-compose.yml) - Compose file used in [CI build](.github/workflows/build.yml)
57+
- [Dockerfile](Dockerfile) - Builder image used in [docker-compose.yml](docker-compose.yml) and [devcontainer.json](.devcontainer/devcontainer.json)
58+
- [magefile.go](magefile.go) - Mage targets used in [docker-compose.yml](docker-compose.yml) and [.vscode/tasks.json](.vscode/tasks.json)
59+
60+
## FAQ
61+
62+
### Why Mage instead of Make
63+
64+
Here is [why](https://github.com/magefile/mage#why).
65+
However, updating to Make is pretty straightforward.
66+
67+
1. Replace [magefile.go](magefile.go) with a `Makefile` file:
68+
69+
```make
70+
.DEFAULT_GOAL := help
71+
72+
.PHONY: all
73+
all: ## full build: build, lint, test
74+
all: build lint test
75+
76+
.PHONY: build
77+
build: ## go build
78+
go build ./...
79+
80+
.PHONY: lint
81+
lint: ## golangci-lint
82+
golangci-lint run
83+
84+
.PHONY: test
85+
test: ## go test with race detector and code covarage
86+
go test -race -covermode=atomic
87+
88+
.PHONY: help
89+
help:
90+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
91+
```
92+
93+
2. Remove Mage installation from [Dockerfile](Dockerfile).
94+
1. Update [docker-compose.yml](docker-compose.yml) and [.vscode/tasks.json](.vscode/tasks.json) to use `make`.
95+
96+
If you want to use Make on bare-metal Windows, then you can use [WSL (Windows Subsystem for Linux)](https://docs.microsoft.com/en-us/windows/wsl/install-win10) or install [Make Windows port to Git Bash](https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058).
97+
98+
### Why nothing for GoLand
99+
100+
The maintainer does not use GoLand. Fell free to create a pull request for [#2](https://github.com/golang-templates/library/issues/2).
101+
102+
### Why GitHub Actions, not any other CI server
103+
104+
GitHub Actions is out-of-the-box if you are already using GitHub.
105+
However, changing to any other CI server should be very simple, because this repository uses Docker Compose to run CI build to make the transition easy.
106+
107+
For [CircleCI](https://circleci.com/docs/2.0/executor-types/#using-machine) create `.circleci/config.yml` file:
108+
109+
```yml
110+
version: 2.1
111+
jobs:
112+
build:
113+
machine:
114+
image: ubuntu-1604:201903-01
115+
steps:
116+
- checkout
117+
- run: docker-compose up --abort-on-container-exit
118+
```
50119

51120
## Contributing
52121

0 commit comments

Comments
 (0)