Anyone can write templates, which are packaged and distributed as modules, leveraging the Go module proxy and checksum database for better security and availability.Anyone can write templates, which are packaged and distributed as modules, leveraging the Go module proxy and checksum database for better security and availability.

Go Project Templates: How to Get Started

2025/09/21 00:00

When you start a new project in Go, you might begin by cloning an existing project. That way, you can start with something that already works, making incremental changes instead of starting from scratch.

\ For a long time now, we have heard from Go developers that getting started is often the hardest part. New developers coming from other languages expect guidance on a default project layout, experienced developers working on teams expect consistency in their projects’ dependencies, and developers of all kinds expect an easy way to try new products and services without having to copy and paste from samples on the web.

\ To that end, today we published gonew, an experimental tool for instantiating new projects in Go from predefined templates. Anyone can write templates, which are packaged and distributed as modules, leveraging the Go module proxy and checksum database for better security and availability.

\ The prototype gonew is intentionally minimal: what we have released today is an extremely limited prototype meant to provide a base from which we can gather feedback and community direction. Try it out, tell us what you think, and help us build a more useful tool for everyone.

Getting started

Start by installing gonew using go install:

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

\ To copy an existing template, run gonew in your new project’s parent directory with two arguments: first, the path to the template you wish to copy, and second, the module name of the project you are creating. For example:

$ gonew golang.org/x/example/helloserver example.com/myserver $ cd ./myserver 

\ And then you can read and edit the files in ./myserver to customize.

\ We’ve written two templates to get you started:

  • hello: A command line tool that prints a greeting, with customization flags.
  • helloserver: An HTTP server that serves greetings.

Write your own templates

Writing your own template is as easy as creating any other module in Go. Check out the examples we linked above to get started.

\ There are also examples available from the Google Cloud and Service Weaver teams.

Next steps

Please try out gonew and let us know how we can make it better and more useful. Remember, gonew is just an experiment for now; we need your feedback to get it right.


Cameron Balahan

\ This article is available on The Go Blog under a CC BY 4.0 DEED license.

\ Photo by Clemens van Lay on Unsplash

ข้อจำกัดความรับผิดชอบ: บทความที่โพสต์ซ้ำในไซต์นี้มาจากแพลตฟอร์มสาธารณะและมีไว้เพื่อจุดประสงค์ในการให้ข้อมูลเท่านั้น ซึ่งไม่ได้สะท้อนถึงมุมมองของ MEXC แต่อย่างใด ลิขสิทธิ์ทั้งหมดยังคงเป็นของผู้เขียนดั้งเดิม หากคุณเชื่อว่าเนื้อหาใดละเมิดสิทธิของบุคคลที่สาม โปรดติดต่อ service@mexc.com เพื่อลบออก MEXC ไม่รับประกันความถูกต้อง ความสมบูรณ์ หรือความทันเวลาของเนื้อหาใดๆ และไม่รับผิดชอบต่อการดำเนินการใดๆ ที่เกิดขึ้นตามข้อมูลที่ให้มา เนื้อหานี้ไม่ถือเป็นคำแนะนำทางการเงิน กฎหมาย หรือคำแนะนำจากผู้เชี่ยวชาญอื่นๆ และไม่ถือว่าเป็นคำแนะนำหรือการรับรองจาก MEXC
แชร์ข้อมูลเชิงลึก

คุณอาจชอบเช่นกัน

Analysts: Expect Bitcoin to experience a sharp correction before hitting a new all-time high

Analysts: Expect Bitcoin to experience a sharp correction before hitting a new all-time high

PANews reported on September 29th that according to Cointelegraph, market analyst Jordi Visser stated that while the fourth quarter is often a buoyant period for crypto asset prices, Bitcoin's path to a record high of $112,046 is subject to corrections of 20% or more, and the fourth quarter is no exception. He compared Bitcoin to Nvidia, which has become the world's most valuable company and the first to reach $4 trillion, noting that in less than three years since the launch of ChatGPT, Nvidia's stock price has risen by over 1,000%, with five corrections of over 20% before reaching new all-time highs. This trend is expected to be true for Bitcoin. Visser predicts that the development of artificial intelligence will erode traditional companies and make stocks obsolete, leading investors to turn to Bitcoin, making it the best store of value in the digital age. Currently, while gold and stocks are reaching new highs, Bitcoin is trading around $110,000, down approximately 11% from its all-time high. Investors are divided on whether Bitcoin can reach new highs in the fourth quarter. Regulatory hurdles and the slow progress of the US's strategic Bitcoin reserve have tempered the expectations of some analysts, who previously believed that government purchases of Bitcoin would be the primary catalyst for Bitcoin's price by 2025.
แชร์
PANews2025/09/29 07:21
แชร์