[Book] Learning Go
Last Update:
Word Count:
Read Time:
El libro
Introduction
This article is used to keep notes and summaries of the book “Learning Go”.
The content will be continuously updated as I read through the book.
Chapter.1 - Setting Up Your Go Environment
The go command
1 | |
1 | |
1 | |
This creates an executable called hello (or hello.exe on Windows) in the current directory.
Makefiles
Here’s a sample Makefile to add to our very simple project:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17.DEFAULT_GOAL := build
fmt:
go fmt ./...
.PHONY:fmt
lint: fmt
golint ./...
.PHONY: lint
vet: fmt
go vet ./...
.PHONY:vet
build: vet
go build hello.go
.PHONY:build
Each possible operation is called a target. The .DEFAULT_GOAL defines which target is run when no target is specified. In our case, we are going to run the build target.
The world before the colon (:) is the name of the target. Any words after the target (like vet in the line build: vet) are the other targets that must be run before the specified target runs. The taks that are performed by the target are on the indented lines after the target (The)
Once theMakefile is in your directory, type:1
> make