| <!--{ |
| "Title": "Documentation", |
| "Template": true |
| }--> |
| |
| <p> |
| The Go programming language is an open source project to make programmers more |
| productive. |
| </p> |
| |
| <p> |
| Go is expressive, concise, clean, and efficient. Its concurrency |
| mechanisms make it easy to write programs that get the most out of multicore |
| and networked machines, while its novel type system enables flexible and |
| modular program construction. Go compiles quickly to machine code yet has the |
| convenience of garbage collection and the power of run-time reflection. It's a |
| fast, statically typed, compiled language that feels like a dynamically typed, |
| interpreted language. |
| </p> |
| |
| <div id="manual-nav"></div> |
| |
| <h2 id="getting-started">Getting started</h2> |
| |
| <h3 id="installing"><a href="/doc/install">Installing Go</a></h3> |
| <p> |
| Instructions for downloading and installing Go. |
| </p> |
| |
| <h3 id="get-started-tutorial"><a href="/doc/tutorial/getting-started.html">Tutorial: Getting started</a></h3> |
| <p> |
| A brief Hello, World tutorial to get started. Learn a bit about Go code, tools, packages, and modules. |
| </p> |
| |
| <h3 id="create-module-tutorial"><a href="/doc/tutorial/create-module.html">Tutorial: Create a module</a></h3> |
| <p> |
| A tutorial of short topics introducing functions, error handling, arrays, maps, unit testing, and compiling. |
| </p> |
| |
| <h3 id="writing-web-applications"><a href="/doc/articles/wiki/">Writing Web Applications</a></h3> |
| <p> |
| Building a simple web application. |
| </p> |
| |
| <h3 id="code"><a href="code.html">How to write Go code</a></h3> |
| <p> |
| This doc explains how to develop a simple set of Go packages inside a module, |
| and it shows how to use the <a href="/cmd/go/"><code>go</code> command</a> |
| to build and test packages. |
| </p> |
| |
| <img class="gopher" src="/doc/gopher/doc.png" alt=""/> |
| |
| <h3 id="go_tour"> |
| {{if $.GoogleCN}} |
| A Tour of Go |
| {{else}} |
| <a href="//tour.golang.org/">A Tour of Go</a> |
| {{end}} |
| </h3> |
| <p> |
| An interactive introduction to Go in three sections. |
| The first section covers basic syntax and data structures; the second discusses |
| methods and interfaces; and the third introduces Go's concurrency primitives. |
| Each section concludes with a few exercises so you can practice what you've |
| learned. You can {{if not $.GoogleCN}}<a href="//tour.golang.org/">take the tour |
| online</a> or{{end}} install it locally with: |
| </p> |
| <pre> |
| $ go get golang.org/x/tour |
| </pre> |
| <p> |
| This will place the <code>tour</code> binary in your workspace's <code>bin</code> directory. |
| </p> |
| |
| <h2 id="learning">Using and understanding Go</h2> |
| |
| <h3 id="effective_go"><a href="effective_go.html">Effective Go</a></h3> |
| <p> |
| A document that gives tips for writing clear, idiomatic Go code. |
| A must read for any new Go programmer. It augments the tour and |
| the language specification, both of which should be read first. |
| </p> |
| |
| <h3 id="editors"><a href="editors.html">Editor plugins and IDEs</a></h3> |
| <p> |
| A document that summarizes commonly used editor plugins and IDEs with |
| Go support. |
| </p> |
| |
| <h3 id="diagnostics"><a href="/doc/diagnostics.html">Diagnostics</a></h3> |
| <p> |
| Summarizes tools and methodologies to diagnose problems in Go programs. |
| </p> |
| |
| <h3 id="dependencies"><a href="/doc/modules/managing-dependencies">Managing dependencies</a></h3> |
| <p> |
| When your code uses external packages, those packages (distributed as modules) become dependencies. |
| </p> |
| |
| <h3 id="developing-modules">Developing modules</h3> |
| |
| <h4 id="modules-develop-publish"><a href="/doc/modules/developing">Developing and publishing modules</a></h4> |
| <p> |
| You can collect related packages into modules, then publish the modules for other developers to use. This topic gives an overview of developing and publishing modules. |
| </p> |
| |
| <h4 id="modules-release-workflow"><a href="/doc/modules/release-workflow">Module release and versioning workflow</a></h4> |
| <p> |
| When you develop modules for use by other developers, you can follow a workflow that helps ensure a reliable, consistent experience for developers using the module. This topic describes the high-level steps in that workflow. |
| </p> |
| |
| <h4 id="modules-managing-source"><a href="/doc/modules/managing-source">Managing module source</a></h4> |
| <p> |
| When you're developing modules to publish for others to use, you can help ensure that your modules are easier for other developers to use by following the repository conventions described in this topic. |
| </p> |
| |
| <h4 id="modules-major-version"><a href="/doc/modules/major-version">Developing a major version update</a></h4> |
| <p> |
| A major version update can be very disruptive to your module's users because it includes breaking changes and represents a new module. Learn more in this topic. |
| </p> |
| |
| <h4 id="modules-publishing"><a href="/doc/modules/publishing">Publishing a module</a></h4> |
| <p> |
| When you want to make a module available for other developers, you publish it so that it's visible to Go tools. Once you've published the module, developers importing its packages will be able to resolve a dependency on the module by running commands such as go get. |
| </p> |
| |
| <h4 id="modules-version-numbers"><a href="/doc/modules/version-numbers">Module version numbering</a></h4> |
| <p> |
| A module's developer uses each part of a module's version number to signal the version’s stability and backward compatibility. For each new release, a module's release version number specifically reflects the nature of the module's changes since the preceding release. |
| </p> |
| |
| <h3 id="faq"><a href="/doc/faq">Frequently Asked Questions (FAQ)</a></h3> |
| <p> |
| Answers to common questions about Go. |
| </p> |
| |
| <h2 id="references">References</h2> |
| |
| <h3 id="pkg"><a href="/pkg/">Package Documentation</a></h3> |
| <p> |
| The documentation for the Go standard library. |
| </p> |
| |
| <h3 id="cmd"><a href="/doc/cmd">Command Documentation</a></h3> |
| <p> |
| The documentation for the Go tools. |
| </p> |
| |
| <h3 id="spec"><a href="/ref/spec">Language Specification</a></h3> |
| <p> |
| The official Go Language specification. |
| </p> |
| |
| <h3 id="mod"><a href="/ref/mod">Go Modules Reference</a></h3> |
| <p> |
| A detailed reference manual for Go's dependency management system. |
| </p> |
| |
| <h3><a href="/doc/modules/gomod-ref">go.mod file reference</a></h3> |
| <p> |
| Reference for the directives included in a go.mod file. |
| </p> |
| |
| <h3 id="go_mem"><a href="/ref/mem">The Go Memory Model</a></h3> |
| <p> |
| A document that specifies the conditions under which reads of a variable in |
| one goroutine can be guaranteed to observe values produced by writes to the |
| same variable in a different goroutine. |
| </p> |
| |
| <h3 id="release"><a href="/doc/devel/release.html">Release History</a></h3> |
| <p>A summary of the changes between Go releases.</p> |
| |
| <h2 id="codewalks">Codewalks</h2> |
| <p> |
| Guided tours of Go programs. |
| </p> |
| <ul> |
| <li><a href="/doc/codewalk/functions">First-Class Functions in Go</a></li> |
| <li><a href="/doc/codewalk/markov">Generating arbitrary text: a Markov chain algorithm</a></li> |
| <li><a href="/doc/codewalk/sharemem">Share Memory by Communicating</a></li> |
| </ul> |
| |
| {{if not $.GoogleCN}} |
| <h2 id="blog">From the Go Blog</h2> |
| <p>The <a href="//blog.golang.org/">official blog of the Go project</a>, featuring news and in-depth articles by |
| the Go team and guests.</p> |
| |
| <h4>Language</h4> |
| <ul> |
| <li><a href="/blog/json-rpc-tale-of-interfaces">JSON-RPC: a tale of interfaces</a></li> |
| <li><a href="/blog/gos-declaration-syntax">Go's Declaration Syntax</a></li> |
| <li><a href="/blog/defer-panic-and-recover">Defer, Panic, and Recover</a></li> |
| <li><a href="/blog/go-concurrency-patterns-timing-out-and">Go Concurrency Patterns: Timing out, moving on</a></li> |
| <li><a href="/blog/go-slices-usage-and-internals">Go Slices: usage and internals</a></li> |
| <li><a href="/blog/gif-decoder-exercise-in-go-interfaces">A GIF decoder: an exercise in Go interfaces</a></li> |
| <li><a href="/blog/error-handling-and-go">Error Handling and Go</a></li> |
| <li><a href="/blog/organizing-go-code">Organizing Go code</a></li> |
| </ul> |
| |
| <h4>Packages</h4> |
| <ul> |
| <li><a href="/blog/json-and-go">JSON and Go</a> - using the <a href="/pkg/encoding/json/">json</a> package.</li> |
| <li><a href="/blog/gobs-of-data">Gobs of data</a> - the design and use of the <a href="/pkg/encoding/gob/">gob</a> package.</li> |
| <li><a href="/blog/laws-of-reflection">The Laws of Reflection</a> - the fundamentals of the <a href="/pkg/reflect/">reflect</a> package.</li> |
| <li><a href="/blog/go-image-package">The Go image package</a> - the fundamentals of the <a href="/pkg/image/">image</a> package.</li> |
| <li><a href="/blog/go-imagedraw-package">The Go image/draw package</a> - the fundamentals of the <a href="/pkg/image/draw/">image/draw</a> package.</li> |
| </ul> |
| |
| <h4>Modules</h4> |
| <ul> |
| <li><a href="/blog/using-go-modules">Using Go Modules</a> - an introduction to using modules in a simple project.</li> |
| <li><a href="/blog/migrating-to-go-modules">Migrating to Go Modules</a> - converting an existing project to use modules.</li> |
| <li><a href="/blog/publishing-go-modules">Publishing Go Modules</a> - how to make new versions of modules available to others.</li> |
| <li><a href="/blog/v2-go-modules">Go Modules: v2 and Beyond</a> - creating and publishing major versions 2 and higher.</li> |
| <li><a href="/blog/module-compatibility">Keeping Your Modules Compatible</a> - how to keep your modules compatible with prior minor/patch versions.</li> |
| </ul> |
| {{end}} |
| |
| <h4>Tools</h4> |
| <ul> |
| <li><a href="/doc/articles/go_command.html">About the Go command</a> - why we wrote it, what it is, what it's not, and how to use it.</li> |
| <li><a href="/doc/gdb">Debugging Go Code with GDB</a></li> |
| <li><a href="/doc/articles/race_detector.html">Data Race Detector</a> - a manual for the data race detector.</li> |
| <li><a href="/doc/asm">A Quick Guide to Go's Assembler</a> - an introduction to the assembler used by Go.</li> |
| {{if not $.GoogleCN}} |
| <li><a href="/blog/c-go-cgo">C? Go? Cgo!</a> - linking against C code with <a href="/cmd/cgo/">cgo</a>.</li> |
| <li><a href="/blog/godoc-documenting-go-code">Godoc: documenting Go code</a> - writing good documentation for <a href="/cmd/godoc/">godoc</a>.</li> |
| <li><a href="/blog/profiling-go-programs">Profiling Go Programs</a></li> |
| <li><a href="/blog/race-detector">Introducing the Go Race Detector</a> - an introduction to the race detector.</li> |
| {{end}} |
| </ul> |
| |
| <h2 id="wiki">Wiki</h2> |
| <p> |
| The <a href="/wiki">Go Wiki</a>, maintained by the Go community, includes articles about the Go language, tools, and other resources. |
| </p> |
| |
| <p id="learn_more"> |
| See the <a href="/wiki/Learn">Learn</a> page at the <a href="/wiki">Wiki</a> |
| for more Go learning resources. |
| </p> |
| |
| {{if not $.GoogleCN}} |
| <h2 id="talks">Talks</h2> |
| |
| <img class="gopher" src="/doc/gopher/talks.png" alt=""/> |
| |
| <h3 id="video_tour_of_go"><a href="https://research.swtch.com/gotour">A Video Tour of Go</a></h3> |
| <p> |
| Three things that make Go fast, fun, and productive: |
| interfaces, reflection, and concurrency. Builds a toy web crawler to |
| demonstrate these. |
| </p> |
| |
| <h3 id="go_code_that_grows"><a href="//vimeo.com/53221560">Code that grows with grace</a></h3> |
| <p> |
| One of Go's key design goals is code adaptability; that it should be easy to take a simple design and build upon it in a clean and natural way. In this talk Andrew Gerrand describes a simple "chat roulette" server that matches pairs of incoming TCP connections, and then use Go's concurrency mechanisms, interfaces, and standard library to extend it with a web interface and other features. While the function of the program changes dramatically, Go's flexibility preserves the original design as it grows. |
| </p> |
| |
| <h3 id="go_concurrency_patterns"><a href="//www.youtube.com/watch?v=f6kdp27TYZs">Go Concurrency Patterns</a></h3> |
| <p> |
| Concurrency is the key to designing high performance network services. Go's concurrency primitives (goroutines and channels) provide a simple and efficient means of expressing concurrent execution. In this talk we see how tricky concurrency problems can be solved gracefully with simple Go code. |
| </p> |
| |
| <h3 id="advanced_go_concurrency_patterns"><a href="//www.youtube.com/watch?v=QDDwwePbDtw">Advanced Go Concurrency Patterns</a></h3> |
| <p> |
| This talk expands on the <i>Go Concurrency Patterns</i> talk to dive deeper into Go's concurrency primitives. |
| </p> |
| |
| <h4 id="talks_more">More</h4> |
| <p> |
| See the <a href="/talks">Go Talks site</a> and <a href="/wiki/GoTalks">wiki page</a> for more Go talks. |
| </p> |
| {{end}} |
| |
| <h2 id="nonenglish">Non-English Documentation</h2> |
| |
| <p> |
| See the <a href="/wiki/NonEnglish">NonEnglish</a> page |
| at the <a href="/wiki">Wiki</a> for localized |
| documentation. |
| </p> |