Unveiling gonew: A Rapid Launchpad for Go Projects

From Source Code Analysis to Template Utilization: Mastering the Power of gonew

Stefanie Lai
5 min readJan 25, 2024
from Unsplash

Organize Your Go Project Gracefully has walked you through how to layout the Go project reasonably to facilitate expansion, and avoid circular dependencies between packages.

However, you may wonder whether there is a tool like Maven that can help with the quick build of the Go project framework to save us from the step-by-step process of creating folders, go mod files, cmd, and go files. Of course, there is! gonew, which is no longer new, can facilitate the creation of Go code frameworks based on GitHub projects.

Try gonew Out

Download.

go install golang.org/x/tools/cmd/gonew@latest

go: downloading golang.org/x/tools v0.17.0
go: downloading golang.org/x/mod v0.14.0

Check out the usage.

gonew -h
usage: gonew srcmod[@version] [dstmod [dir]]

Execute the following command to generate an httpserver code framework, including all the content the project requires, such as mod files, go files, and test files.

gonew golang.org/x/example/helloserver slaise.se/myserver

--

--