Giter VIP home page Giter VIP logo

hellogopher's Introduction

Makefile for Go projects

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

This is for people who don't know about GOPATH or who don't want to use it (like me). With such a Makefile, a project can be built whatever its location on the disk.

This is intended for programs only. For libraries, you should be able to use go build, go install, go get directly or you will make the life of your users difficult.

Also, it is not intended to be an universal Makefile. It should stay basic to stay easy to understand.

Vendoring

This example relies on vendoring for all dependencies. It uses Glide for this purpose. It is expected to be already installed (but look at how other tools are installed, it's easy to do the same thing for Glide).

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-xml for tests with xUnit-compatible output
  • make test-coverage for test coverage (will output index.html, coverage.xml and profile.out in test/coverage.*/.
  • make test PKG=helloworld/hello to restrict test to a package
  • make clean
  • make vendor to retrieve dependencies
  • 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.

hellogopher's People

Contributors

vincentbernat avatar

Watchers

Sebastian Choren avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.