Skip to content

Commit c7f4d8a

Browse files
authored
Use Make instead of Mage. Rename project (#3)
1 parent 0cc107b commit c7f4d8a

File tree

11 files changed

+77
-104
lines changed

11 files changed

+77
-104
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
linters-settings:
22
goimports:
3-
local-prefixes: github.com/golang-templates/library
3+
local-prefixes: github.com/golang-templates/seed
44
golint:
55
min-confidence: 0
66
misspell:

.vscode/tasks.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"label": "All",
7+
"label": "all",
88
"type": "shell",
9-
"command": "mage -v all",
9+
"command": "make all",
1010
"problemMatcher": [
1111
"$go"
1212
],
1313
"group": "build"
1414
},
1515
{
16-
"label": "Build",
16+
"label": "build",
1717
"type": "shell",
18-
"command": "mage -v build",
18+
"command": "make build",
1919
"problemMatcher": [
2020
"$go"
2121
],
2222
"group": "build"
2323
},
2424
{
25-
"label": "Lint",
25+
"label": "lint",
2626
"type": "shell",
27-
"command": "mage -v lint",
27+
"command": "make lint",
2828
"problemMatcher": [
2929
"$go"
3030
],
3131
"group": "build"
3232
},
3333
{
34-
"label": "Test",
34+
"label": "test",
3535
"type": "shell",
36-
"command": "mage -v test",
36+
"command": "make test",
3737
"problemMatcher": [
3838
"$go"
3939
],

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# go
22
FROM golang:1.14.2
3-
# mage
4-
RUN GO111MODULE=on go get github.com/magefile/[email protected]
53
# golangci-lint
64
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.26.0

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.DEFAULT_GOAL := help
2+
3+
.PHONY: all
4+
all: ## full build: build, lint, test
5+
all: build lint test
6+
7+
.PHONY: build
8+
build: ## go build
9+
$(call print-target)
10+
go build ./...
11+
12+
.PHONY: lint
13+
lint: ## golangci-lint
14+
$(call print-target)
15+
golangci-lint run
16+
17+
.PHONY: test
18+
test: ## go test with race detector and code covarage
19+
$(call print-target)
20+
go test -race -covermode=atomic
21+
22+
.PHONY: help
23+
help:
24+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
25+
26+
define print-target
27+
@echo "Executing target: \033[36m$@\033[0m"
28+
endef

README.md

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,63 @@
1-
# Go Library Template
1+
# Go Project Template
22

3-
[![Build Status](https://github.com/golang-templates/library/workflows/build/badge.svg)](https://github.com/golang-templates/library/actions?query=workflow%3Abuild)
4-
[![GoDoc](https://godoc.org/github.com/golang-templates/library?status.svg)](https://godoc.org/github.com/golang-templates/library)
5-
[![GitHub Release](https://img.shields.io/github/release/golang-templates/library.svg)](https://github.com/golang-templates/library/releases)
6-
[![Go Report Card](https://goreportcard.com/badge/github.com/golang-templates/library)](https://goreportcard.com/report/github.com/golang-templates/library)
3+
[![Build Status](https://github.com/golang-templates/seed/workflows/build/badge.svg)](https://github.com/golang-templates/seed/actions?query=workflow%3Abuild)
4+
[![GoDoc](https://godoc.org/github.com/golang-templates/seed?status.svg)](https://godoc.org/github.com/golang-templates/seed)
5+
[![GitHub Release](https://img.shields.io/github/release/golang-templates/seed.svg)](https://github.com/golang-templates/seed/releases)
6+
[![Go Report Card](https://goreportcard.com/badge/github.com/golang-templates/seed)](https://goreportcard.com/report/github.com/golang-templates/seed)
77

8-
This is GitHub project template for a Go library. It has been created for ease-of-use for anyone who wants to:
8+
This is GitHub project template for Go. 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,
11-
- create a new repoisitory with basic Continous Integration,
12-
- write Go code on Linux, MacOS, Windows.
11+
- create a new repoisitory with basic Continous Integration.
1312

1413
It includes:
1514

1615
- [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,
1716
- dependency management using [Go Modules](https://github.com/golang/go/wiki/Modules),
1817
- 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).
18+
- build automation via [Make](https://www.gnu.org/software/make), [Docker](https://docs.docker.com/engine), [Docker Compose](https://docs.docker.com/compose), [GitHub Actions](https://github.com/features/actions).
2019

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

2322
## Usage
2423

2524
1. Click the `Use this template` button (alt. clone or download this repository).
26-
1. Replace all occurences of `golang-templates/library` to `your_org/repo_name` in all files.
25+
1. Replace all occurences of `golang-templates/seed` to `your_org/repo_name` in all files.
2726
1. Change [LICENSE](LICENSE) and [README.md](README.md).
2827

29-
### Setup Development Environment
28+
### Setup Development Environment - Visual Studio Code
3029

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.
30+
#### Visual Studio Code - Bare-metal
3231

33-
- **Bare metal:** See [Dockerfile](Dockerfile) for Mage and GolangCI-Lint installation commands.
34-
- **Containers:** [Instructions](https://code.visualstudio.com/docs/remote/containers).
35-
- **Remote via SSH**: [Instructions](https://code.visualstudio.com/docs/remote/ssh).
32+
1. Install [Go](https://golang.org/doc/install) and [Go extension](https://code.visualstudio.com/docs/languages/go).
33+
1. Visual Studio Code: `View``Command Pallete... (F1)` → Select `Go: Install/Update Tools`.
34+
1. See [Dockerfile](Dockerfile) for GolangCI-Lint installation command.
35+
36+
#### Visual Studio Code - Development Container
37+
38+
1. [Setup Development inside a Container](https://code.visualstudio.com/docs/remote/containers#_getting-started).
39+
1. Visual Studio Code inside Container: `View``Command Pallete... (F1)` → Select `Go: Install/Update Tools`.
40+
1. See [Dockerfile](Dockerfile) for GolangCI-Lint installation command.
41+
42+
#### Visual Studio Code - SSH
43+
44+
1. [Setup Remote Development using SSH](https://code.visualstudio.com/docs/remote/ssh#_getting-started).
45+
1. On remote machine: install [Go](https://golang.org/doc/install) and [Go extension](https://code.visualstudio.com/docs/languages/go).
46+
1. Visual Studio Code: `View``Command Pallete... (F1)` → Select `Go: Install/Update Tools`.
47+
1. See [Dockerfile](Dockerfile) for GolangCI-Lint installation command.
3648

3749
### Build
3850

39-
- Terminal: `mage -v all`.
51+
- Terminal: `make all`.
4052
- Visual Studio Code: `Terminal``Run Build Task... (CTRL+ALT+B)` → Select `All`.
4153
- Terminal: `docker-compose up --abort-on-container-exit`. This command is executed by CI build (GitHub Action workflow).
4254

4355
### Maintainance
4456

4557
1. `Watch` this project to get notified about new releases, issues, etc.
46-
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.
58+
1. Update Go and GolangCI-Lint version in [Dockerfile](Dockerfile).
4759
1. Configure linters via [.golangci.yml](.golangci.yml).
48-
1. Develop Mage targets in [magefile.go](magefile.go) and assosiated tasks in [.vscode/tasks.json](.vscode/tasks.json).
60+
1. Develop Make targets in [Makefile](Makefile) and assosiated tasks in [.vscode/tasks.json](.vscode/tasks.json).
4961

5062
Notable files:
5163

@@ -55,49 +67,17 @@ Notable files:
5567
- [.golangci.yml](.golangci.yml) - GolangCI-Lint configuration
5668
- [docker-compose.yml](docker-compose.yml) - Compose file used in [CI build](.github/workflows/build.yml)
5769
- [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)
70+
- [Makefile](Makefile) - Make targets used in [docker-compose.yml](docker-compose.yml) and [.vscode/tasks.json](.vscode/tasks.json)
5971

6072
## FAQ
6173

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`.
74+
### Make does not work on Windows
9575

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).
76+
You can use [WSL (Windows Subsystem for Linux)](https://docs.microsoft.com/en-us/windows/wsl/install-win10) or try [Make Windows port](https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058).
9777

9878
### Why nothing for GoLand
9979

100-
The maintainer does not use GoLand. Fell free to create a pull request for [#2](https://github.com/golang-templates/library/issues/2).
80+
The maintainer does not use GoLand. Fell free to create a pull request for [#2](https://github.com/golang-templates/seed/issues/2).
10181

10282
### Why GitHub Actions, not any other CI server
10383

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ services:
44
container_name: builder
55
build: .
66
working_dir: /app
7-
command: mage -v all
7+
command: make all
88
volumes:
99
- $PWD:/app
10-

foo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Package library has a dummy function covered by a unit test.
2-
package library
1+
// Package seed has a dummy function covered by a unit test.
2+
package seed
33

44
// Foo returns "Bar".
55
func Foo() string {

foo_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package library_test
1+
package seed_test
22

33
import (
44
"testing"
55

6-
. "github.com/golang-templates/library"
6+
. "github.com/golang-templates/seed"
77
)
88

99
func TestFoo(t *testing.T) {

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
module github.com/golang-templates/library
1+
module github.com/golang-templates/seed
22

33
go 1.14
4-
5-
require github.com/magefile/mage v1.9.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
github.com/magefile/mage v1.9.0 h1:t3AU2wNwehMCW97vuqQLtw6puppWXHO+O2MHo5a50XE=
2-
github.com/magefile/mage v1.9.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=

0 commit comments

Comments
 (0)