• Stars
    star
    301
  • Rank 138,451 (Top 3 %)
  • Language Makefile
  • License
    Creative Commons ...
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Makefile to build a Go project

Makefile for Go projects (1.16+)

This is an example of Makefile to build a Go project. This is quite similar to Filippo Valsorda's hellogopher.

Initially, this is for people who don't know about GOPATH or who don't want to use it (like me). However, starting with Go 1.11, modules enable to work outside of GOPATH without any special environment. This turns this Makefile as only a convenience tool.

This Makefile may not be used as is. It is expected to be modified to fit your needs. See Akvorado's Makefile for an example on a more complex project.

Dependencies

This example relies on modules to retrieve dependencies. This requires use of Go 1.11 or more recent. To update a dependency, use go get DEPENDENCY@REVISION.

We also rely on go install TOOL@latest which requires Go 1.16. You can checkout tag v0.6 if you need compatibility up to Go 1.11.

On first build, you need to run go mod init PROJECTNAME.

Versioning

Version is extracted from git tags using anything prefixed by v.

Usage

The following commands are available:

  • make help to get help
  • make to build the binary (in bin/)
  • make test to run tests
  • make test-verbose to run tests in verbose mode
  • make test-race for race tests
  • make test-coverage for test coverage (will output coverage.html and coverage.xml in test/.
  • make test PKG=helloworld/hello to restrict test to a package
  • make clean
  • make lint to run golint
  • make fmt to run gofmt

The very first line of the Makefile is the most important one: this is the path of the package. I don't use a go getable package path but you can.

Be sure to browse the remaining of the Makefile to understand what it does. There are some tools that will be downloaded. You can use already-installed one by specifying their full path this way instead:

make lint GOLINT=/usr/bin/golint

Files other than .gitignore and Makefile are just examples.

Misc

If golint complains with go/build: importGo hellogopher/cmd: exit status 2, just delete it from bin/ and let the Makefile build it again.

If you prefer, you can also include this Makefile into another one. Rename it to hellogopher.mk and put in Makefile something like this:

include hellogopher.mk

# Your custom settings
TIMEOUT=10

# Your custom rules
doc: ; $(info $(M) build documentation) @ ## Build documentation
	$(MAKE) -C doc

License

This Makefile is published under the CC0 1.0 license. See LICENSE for more details.

More Repositories

1

network-lab

Networking lab using root-less VM
Shell
528
star
2

dashkiosk

Managing dashboards on various displays (especially those running on Android)
JavaScript
354
star
3

rfc5077

Various tools for testing RFC 5077
C
241
star
4

nodecastor

Experiment to implement a sender API for Chromecast in Node.js
JavaScript
180
star
5

snimpy

interactive SNMP tool with Python
Python
180
star
6

video2hls

Prepare a video to be streamed with HLS
Python
171
star
7

awesome-configuration

My ~/.config/awesome directory
Lua
127
star
8

eudyptula-boot

Boot a Linux kernel in a VM without a dedicated root filesystem.
Shell
112
star
9

pragmatic-debian-packages

Pragmatic Debian packaging
Makefile
98
star
10

serverspec-example

Advanced use example of serverspec
JavaScript
98
star
11

jchroot

a chroot with more isolation
C
96
star
12

wiremaps

layer 2 network discovery application
Python
89
star
13

zshrc

My .zshrc
Shell
84
star
14

bootstrap.c

Boilerplate for small C projects (autotools)
C
74
star
15

i3wm-configuration

Python
72
star
16

vincent.bernat.ch

My own website
HTML
71
star
17

extend-netsnmp

Various examples on how to extend NetSNMP agent
C
46
star
18

ssl-dos

Various tools related to SSL denial of service
C
46
star
19

python-script

Sample self-contained Python script
Python
36
star
20

systemtap-cookbook

Some tools using systemtap
Python
29
star
21

vbeterm

Custom terminal based on VTE
C
21
star
22

xssproxy

Forward freedesktop.org Idle Inhibition Service calls to Xss
C
20
star
23

ip_vs_mh

Backport of ip_vs_mh for Linux (consistent hashing with Google's Maglev algorithm)
C
17
star
24

lanco

task launcher which does not want to be an init program
C
16
star
25

bootstrap.c-web

Boilerplate for small C projects (autotools) exporting a REST+SSE+WS API
C
14
star
26

puppet-workstation

Puppet setup to install my own workstation
Puppet
14
star
27

udpproxy

a Netfilter powered UDP proxy
C
13
star
28

cve-2015-3456

Experiments related to CVE-2015-3456
C
12
star
29

puppet-eizo

Puppet repository for "eizo"
Shell
12
star
30

ethtool-snmpd

Export ethtool stuff through SNMP
C
12
star
31

dot.emacs

My Emacs (and Gnus) configuration files
Emacs Lisp
12
star
32

fvwm-configuration

My configuration for fvwm
Shell
11
star
33

dashkiosk-android

Android application for Dashkiosk
Java
9
star
34

ansible-custom-module-examples

See https://vincent.bernat.ch/en/blog/2020-custom-ansible-module
Python
9
star
35

haproxy-debian-repository-wizard

Web application to select the appropriate Debian repository for HAProxy
HTML
9
star
36

junos-mode

Emacs major mode for JunOS configuration file
Emacs Lisp
9
star
37

ripe-atlas-lowest-latency

RIPE Atlas tool to determine the endpoint with the lowest latency
Python
8
star
38

ip_vs_csh

Consistent source hashing scheduler for Linux IPVS
C
8
star
39

ro-ro-tcp

performance enhancing proxy for TCP over links with high latency and moderate error rates
C
8
star
40

vpnoo

an IPSEc + XAuth client for Mac OS X
C
8
star
41

asn2org

AS numbers to organization names
Python
7
star
42

nixops-take1

Playground for NixOps
Nix
7
star
43

quagga

Quagga is free software that manages various IPv4 and IPv6 routing protocols.
C
5
star
44

flappy-bird-reborn-multiplayer

A "Flappy Bird" clone with multiplayer ability.
JavaScript
4
star
45

old-turbo-pascal-programs

Old programs that I wrote when I was a kid.
Pascal
4
star
46

cdktf-take1

Musing around CDKTF
TypeScript
3
star
47

splitpkcs12

PKCS#12 certificate splitter
C
3
star
48

net-snmp

Net-SNMP (not official)
C
3
star
49

ipoo

gather information about IP and hostnames
Python
3
star
50

dosbox

DOSBox, an x86 emulator with DOS. โš ๏ธ Not official. Not a complete mirror. Not updated.
C++
3
star
51

last-resort-gateway

Manage a last resort gateway
Go
2
star
52

pulumi-vultr

Pulumi provider for Vultr (based on the Terraform one), not official
Python
2
star
53

pygments-junos

JunOS lexer for pygments
Python
2
star
54

pygments-ios

IOS lexer for pygments
Python
2
star
55

homemanager-configuration

home-manager configuration for use with Debian Sid
Nix
2
star
56

www.une-oasis-une-ecole.fr

Source code for http://www.une-oasis-une-ecole.fr
HTML
2
star
57

Kitero

Interface and QoS switcher for router
Python
2
star
58

pulumi-gandi-old

Pulumi provider for Gandi, based on Terraform, not official
Python
1
star
59

pygments-haproxy

HAProxy lexer for Pygments
Python
1
star
60

QCss-3

load-balancer web service
Python
1
star