Makefile on MAC OS
On Unix systems, a Makefile is a text file that contains a set of rules for building a program or a set of programs. Make is a build automation tool that reads these rules and uses them to build the program or programs.
Makefiles are often used to automate the process of building and compiling software on Unix-based systems, including Linux and macOS. A typical Makefile consists of a set of targets and dependencies, where each target represents a file that needs to be built, and each dependency represents a file that the target depends on.
create makefile
# Define the Go compiler and linker
GO := go
GOLDFLAGS := -ldflags="-s -w"
# Build go app
build:
$(GO) build $(GOLDFLAGS) -o my_app
run:
./my_app
# Define a "clean" target to remove generated files
clean:
rm -f my_app
create go file with name main.go
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello, World!")
}

wahyu@wahyus-mbp hallo % make clean
rm -f my_app
wahyu@wahyus-mbp hallo % make build
go build -ldflags="-s -w" -o my_app
wahyu@wahyus-mbp hallo % make run
./my_app
Hello, World!
wahyu@wahyus-mbp hallo %