https://go.dev/blog/gonew Go Skip to Main Content * Why Go arrow_drop_down Press Enter to activate/deactivate dropdown + Case Studies Common problems companies solve with Go + Use Cases Stories about how and why companies use Go + Security How Go can help keep you secure by default * Learn Press Enter to activate/deactivate dropdown * Docs arrow_drop_down Press Enter to activate/deactivate dropdown + Effective Go Tips for writing clear, performant, and idiomatic Go code + Go User Manual A complete introduction to building software with Go + Standard library Reference documentation for Go's standard library + Release Notes Learn what's new in each Go release * Packages Press Enter to activate/deactivate dropdown * Community arrow_drop_down Press Enter to activate/deactivate dropdown + Recorded Talks Videos from prior events + Meetups open_in_new Meet other local Go developers + Conferences open_in_new Learn and network with Go developers from around the world + Go blog The Go project's official blog. + Go project Get help and stay informed from Go + Get connected [google-gro] [github] [twitter] [reddit] [slack] [stack-over] Go. * Why Go navigate_next navigate_beforeWhy Go + Case Studies + Use Cases + Security * Learn * Docs navigate_next navigate_beforeDocs + Effective Go + Go User Manual + Standard library + Release Notes * Packages * Community navigate_next navigate_beforeCommunity + Recorded Talks + Meetups open_in_new + Conferences open_in_new + Go blog + Go project + Get connected [google-gro] [github] [twitter] [reddit] [slack] [stack-over] The Go Blog Experimenting with project templates Cameron Balahan 31 July 2023 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. Previous article: Share your feedback about developing with Go Blog Index Why Go Use Cases Case Studies Get Started Playground Tour Stack Overflow Help Packages Standard Library About Go Packages About Download Blog Issue Tracker Release Notes Brand Guidelines Code of Conduct Connect Twitter GitHub Slack r/golang Meetup Golang Weekly The Go Gopher * Copyright * Terms of Service * Privacy Policy * Report an Issue * System theme Dark theme Light theme Google logo go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic. Learn more. Okay