blob: 8ad201595a1626ebe0fa125e37461bbd2aa65514 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="preconnect" href="https://www.googletagmanager.com">
<script >(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W8MVQXG');</script>
<meta charset="utf-8">
<meta name="description" content="Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#00add8">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Google+Sans:400,500,600|Work+Sans:400,500,600|Roboto:400,500,700|Open+Sans:Source+Code+Pro|Material+Icons">
<link rel="stylesheet" href="/css/styles.css">
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W8MVQXG');</script>
<script src="/js/site.js"></script>
<title>About - go.dev</title>
</head>
<body class="Site">
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W8MVQXG"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<header class="Site-header js-siteHeader">
<div class="Banner">
<div class="Banner-inner">
<div class="Banner-message">Black Lives Matter</div>
<a class="Banner-action"
href="https://support.eji.org/give/153413/#!/donation/checkout"
target="_blank"
rel="noopener">
Support the Equal Justice Initiative
</a>
</div>
</div>
<div class="Header Header--dark">
<nav class="Header-nav">
<a href="https://go.dev/">
<img
class="js-headerLogo Header-logo"
src="/images/go-logo-white.svg"
alt="Go">
</a>
<div class="Header-rightContent">
<form
class="js-searchForm SearchForm" action="https://pkg.go.dev/search" role="search">
<button
class="js-searchFormSubmit SearchForm-submit"
aria-label="Search for a package">
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.76 10.27L17.49 16L16 17.49L10.27 11.76C9.2 12.53 7.91 13 6.5 13C2.91 13 0 10.09 0 6.5C0 2.91 2.91 0 6.5 0C10.09 0 13 2.91 13 6.5C13 7.91 12.53 9.2 11.76 10.27ZM6.5 2C4.01 2 2 4.01 2 6.5C2 8.99 4.01 11 6.5 11C8.99 11 11 8.99 11 6.5C11 4.01 8.99 2 6.5 2Z">
</svg>
</button>
<input class="SearchForm-input" aria-label="Search for a package" type="text" name="q" size="1"
placeholder="Search for a package" autocapitalize="off" autocomplete="off" autocorrect="off"
spellcheck="false" title="Search for a package">
</input>
</form>
<ul class="Header-menu">
<li class="Header-menuItem ">
<a href="/solutions/">Why Go</a>
</li>
<li class="Header-menuItem ">
<a href="/learn/">Getting Started</a>
</li>
<li class="Header-menuItem ">
<a href="https://pkg.go.dev">Discover Packages</a>
</li>
<li class="Header-menuItem Header-menuItem--active">
<a href="/about">About</a>
</li>
</ul>
<button class="Header-navOpen js-headerMenuButton Header-navOpen--white" aria-label="Open navigation.">
</button>
</div>
</nav>
</div>
</header>
<aside class="NavigationDrawer js-header">
<nav class="NavigationDrawer-nav">
<div class="NavigationDrawer-header">
<a href="https://go.dev/">
<img class="NavigationDrawer-logo" src="/images/go-logo-blue.svg" alt="Go.">
</a>
</div>
<ul class="NavigationDrawer-list">
<li class="NavigationDrawer-listItem ">
<a href="/solutions/">Why Go</a>
</li>
<li class="NavigationDrawer-listItem ">
<a href="/learn/">Getting Started</a>
</li>
<li class="NavigationDrawer-listItem ">
<a href="https://pkg.go.dev">Discover Packages</a>
</li>
<li class="NavigationDrawer-listItem ">
<a href="/about">About</a>
</li>
</ul>
</nav>
</aside>
<div class="NavigationDrawer-scrim js-scrim" role="presentation"></div>
<main class="SiteContent SiteContent--default">
<article class="Article ">
<h1>About</h1>
<p><a href="https://go.dev" rel="noreferrer" target="_blank">Go.dev</a> is a companion website to <a href="https://golang.org" rel="noreferrer" target="_blank">golang.org</a>. <a href="https://golang.org" rel="noreferrer" target="_blank">Golang.org</a> is the home of the open source project and distribution, while <a href="https://go.dev" rel="noreferrer" target="_blank">go.dev</a> is the hub for Go users providing centralized and curated resources from across the Go ecosystem.</p>
<p><img
loading="lazy"
class="LargeMedia-image Right"
alt="Go gopher"
src="/images/gophers/pink.svg">
Go.dev provides:</p>
<ol>
<li>Centralized information for Go packages and modules published on index.golang.org.</li>
<li>Essential learning resources</li>
<li>Critical use cases &amp; case studies</li>
</ol>
<p>Go.dev is currently in <a href="https://en.wikipedia.org/wiki/Minimum_viable_product" rel="noreferrer" target="_blank">MVP</a> status. We&rsquo;re proud of what we&rsquo;ve built and excited to share it with the community. We hope you find value and joy in using go.dev. Go.dev only has a small portion of features we intend to build, and we are actively seeking feedback. If you have any ideas, suggestions or issues, please let us know.</p>
<h2 id="adding-a-package">Adding a package</h2>
<p>Data for the site is downloaded from <a href="https://proxy.golang.org/" rel="noreferrer" target="_blank">proxy.golang.org</a>. We monitor the <a href="https://index.golang.org/index" rel="noreferrer" target="_blank">Go Module Index</a> regularly for new packages to add to pkg.go.dev. If you don’t see a package on pkg.go.dev, you can add it by doing one of the following:</p>
<ul>
<li><p>Visiting that page on pkg.go.dev, and clicking the &ldquo;Request&rdquo; button. For example: <br /> https://<span></span>pkg.go.dev/example.com/my/module</p></li>
<li><p>Making a request to proxy.golang.org for the module version, to any endpoint specified by the <a href="https://golang.org/cmd/go/#hdr-Module_proxy_protocol" rel="noreferrer" target="_blank">Module proxy protocol</a>. For example: <br /> https://<span></span>proxy.golang.org/example.com/my/module/@v/v1.0.0.info</p></li>
<li><p>Downloading the package via the <a href="https://golang.org/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them" rel="noreferrer" target="_blank">go command</a>. For example: <br /> GOPROXY=https://<span></span>proxy.golang.org GO111MODULE=on go get example.com/my/module@v1.0.0</p></li>
</ul>
<h2 id="removing-a-package">Removing a package</h2>
<p>If you would like to hide versions of a module on pkg.go.dev, as well as from
the <code>go</code> command, you should retract them. Retracting a module version involves
adding a <code>retract</code> directive to your <code>go.mod</code> file and publishing a new version.
See the Go blog post <a href="https://blog.golang.org/go116-module-changes#TOC_5." rel="noreferrer" target="_blank">New module changes in Go
1.16</a> and the <a href="https://golang.org/ref/mod#go-mod-file-retract" rel="noreferrer" target="_blank">modules
reference</a> for details.</p>
<h2 id="documentation">Documentation</h2>
<p>Documentation is generated based on Go source code downloaded from the Go Module Mirror at <code>proxy.golang.org/&lt;module&gt;/@v/&lt;version&gt;.zip</code>. New module versions are fetched from index.golang.org and added to pkg.go.dev site every few minutes.</p>
<p>The <a href="https://blog.golang.org/godoc" rel="noreferrer" target="_blank">guidelines for writing documentation</a> for the godoc tool apply to pkg.go.dev.</p>
<p>It’s important to write a good summary of the package in the first sentence of the package comment. The go.dev site indexes the first sentence and displays it in search results.</p>
<h3 id="build-context">Build Context</h3>
<p>Most Go packages look and behave the same regardless of the machine architecture
or operating system. But some have different documentation, even different
exported symbols, for different architectures or OSes. Some packages may not even
exist for some architectures.</p>
<p>Go calls an OS/architecture pair a &ldquo;build context&rdquo; and writes it with a slash,
like <code>linux/amd64</code>. You may also see the terms <code>GOOS</code> and <code>GOARCH</code> for the OS
and architecture respectively, because those are the names of the environment
variables that the go command uses. (See the <a href="https://golang.org/cmd/go" rel="noreferrer" target="_blank">go command
documentation</a> for more information.)</p>
<p>If a package exists at only one build context, pkg.go.dev displays that build
context at the upper right corner of the documentation. For example,
<a href="https://pkg.go.dev/syscall/js" rel="noreferrer" target="_blank">https://pkg.go.dev/syscall/js</a> displays &ldquo;js/wasm&rdquo;.</p>
<p>If a package is different in different build contexts, then pkg.go.dev will
display one by default and provide a dropdown control at the upper right so you
can select a different one.</p>
<p>For packages that are the same across all build contexts, pkg.go.dev does not
display any build context information.</p>
<p>Although there are many possible OS/architecture pairs, pkg.go.dev considers
only a
<a href="https://go.googlesource.com/pkgsite/+/master/internal/build_context.go#29" rel="noreferrer" target="_blank">handful</a>
of them. So if a package only exists for unsupported build contexts, pkg.go.dev
will not display documentation for it.</p>
<h3 id="source-links">Source Links</h3>
<p>Most of the time, pkg.go.dev can determine the location of a package&rsquo;s source
files, and provide links from symbols in the documentation to their definitions
in the source. If your package&rsquo;s source is not linked, try one of the following
two approaches.</p>
<p>If pkg.go.dev finds a <code>go-source</code> meta tag on your site that follows the
<a href="https://github.com/golang/gddo/wiki/Source-Code-Links" rel="noreferrer" target="_blank">specified format</a>, it
can often determine the right links, even though the format doesn&rsquo;t take
versioning into account.</p>
<p>If that doesn&rsquo;t work, you will need to add your repo or code-hosting site to
pkg.go.dev&rsquo;s list of patterns (see <a href="https://golang.org/issues/40477" rel="noreferrer" target="_blank">Go Issue 40477</a> for context).
Read about how to <a href="https://go.googlesource.com/pkgsite#contributing" rel="noreferrer" target="_blank">contribute to pkg.go.dev</a>,
then produce a CL that adds a pattern to the
<a href="https://go.googlesource.com/pkgsite/+/refs/heads/master/internal/source/source.go" rel="noreferrer" target="_blank"><code>internal/source</code></a>
package.</p>
<h2 id="best-practices">Best practices</h2>
<p>Pkg.go.dev surfaces details about Go packages and modules in order to help provide guidelines for best practices with Go.</p>
<p>Here are the details we surface:</p>
<ul>
<li><p>Has go.mod file</p>
<ul>
<li>The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go. A module version is defined by a tree of source files, with a go.mod file in its root. <a href="https://golang.org/cmd/go/#hdr-The_go_mod_file" rel="noreferrer" target="_blank">More information about the go.mod file</a>.</li>
</ul></li>
<li><p>Redistributable license</p>
<ul>
<li>Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed. For more information on how pkg.go.dev determines if a license is redistributable, see our <a href="http://pkg.go.dev/license-policy" rel="noreferrer" target="_blank">license policy</a>.</li>
</ul></li>
<li><p>Tagged version</p>
<ul>
<li>When the go get command resolves modules by default it prioritizes tagged versions. When no tagged versions exist, go get looks up the latest known commit. Modules with tagged versions give importers more predictable builds. See <a href="https://semver.org" rel="noreferrer" target="_blank">semver.org</a> and <a href="https://blog.golang.org/module-compatibility" rel="noreferrer" target="_blank">Keeping Your Modules Compatible</a> for more information.</li>
</ul></li>
<li><p>Stable version</p>
<ul>
<li>Projects at v0 are assumed to be experimental. When a project reaches a stable version — major version v1 or higher — breaking changes must be done in a new major version. Stable versions give developers the confidence that breaking changes won’t occur when they upgrade a package to the latest minor version. See <a href="https://blog.golang.org/v2-go-modules" rel="noreferrer" target="_blank">Go Modules: v2 and Beyond</a> for more information.</li>
</ul></li>
</ul>
<h2 id="creating-a-badge">Creating a badge</h2>
<p>The pkg.go.dev badge provides a way for Go users to learn about the pkg.go.dev page associated with a given Go package or module. You can create a badge using the <a href="https://pkg.go.dev/badge" rel="noreferrer" target="_blank">badge generation tool</a>. The tool will generate html and markdown snippets that you can use on your project website or in a README file.</p>
<p><a href="https://pkg.go.dev/golang.org/x/pkgsite" rel="noreferrer" target="_blank"><img src="https://pkg.go.dev/badge/golang.org/x/pkgsite" alt="PkgGoDev" /></a></p>
<h2 id="adding-links">Adding links</h2>
<p>You can add links to your README files and package documentation that will be
shown on the right side of the pkg.go.dev page. For details, see <a href="https://golang.org/issue/42968" rel="noreferrer" target="_blank">this
issue</a>.</p>
<h2 id="keyboard-shortcuts">Keyboard Shortcuts</h2>
<p>There are keyboard shortcuts for navigating package documentation pages. Type &lsquo;?&rsquo; on a package page for help.</p>
<h2 id="bookmarklet">Bookmarklet</h2>
<p>The pkg.go.dev bookmarklet navigates from pages on source code hosts, such as GitHub, Bitbucket, Launchpad etc., to the package documentation. To install the bookmarklet, click and drag the following link to your bookmark bar: <a href="javascript:(function(){ const pathRegex = window.location.pathname.match(/([^\/]+)(?:\/([^\/]+))?/); const host = window.location.hostname; if (pathRegex) { window.location='https://pkg.go.dev/'+host+'/'+pathRegex[0]; } else { alert('There was an error navigating to pkg.go.dev!'); } })()">Pkg.go.dev Doc</a></p>
<h2 id="license-policy">License policy</h2>
<p>Information for a given package or module may be limited if we are not able to detect a suitable license. See our <a href="https://pkg.go.dev/license-policy" rel="noreferrer" target="_blank">license policy</a> for more information.</p>
<h2 id="feedback">Feedback</h2>
<p>Share your ideas, feature requests, and bugs on the <a href="https://golang.org/s/discovery-feedback" rel="noreferrer" target="_blank">Go Issue Tracker</a> For questions, please post on the #tools slack channel on the <a href="https://invite.slack.golangbridge.org/" rel="noreferrer" target="_blank">Gophers Slack</a>, or email the <a href="https://groups.google.com/group/golang-dev" rel="noreferrer" target="_blank">golang-dev mailing list</a>.</p>
</article>
</main>
<footer class="Site-footer">
<div class="Footer">
<div class="Container">
<div class="Footer-links">
<div class="Footer-linkColumn">
<a href="/solutions/" class="Footer-link Footer-link--primary">
Why Go
</a>
<a href="/solutions/#use-cases" class="Footer-link">
Use Cases
</a>
<a href="/solutions/#case-studies" class="Footer-link">
Case Studies
</a>
</div>
<div class="Footer-linkColumn">
<a href="/learn/" class="Footer-link Footer-link--primary">
Getting Started
</a>
<a href="https://play.golang.org" class="Footer-link">
Playground
</a>
<a href="https://tour.golang.org" class="Footer-link">
Tour
</a>
<a href="https://stackoverflow.com/questions/tagged/go?tab=Newest" class="Footer-link">
Stack Overflow
</a>
</div>
<div class="Footer-linkColumn">
<a href="https://pkg.go.dev" class="Footer-link Footer-link--primary">
Discover Packages
</a>
</div>
<div class="Footer-linkColumn">
<a href="/about" class="Footer-link Footer-link--primary">
About
</a>
<a href="https://golang.org/dl/" class="Footer-link">
Download
</a>
<a href="https://blog.golang.org" class="Footer-link">
Blog
</a>
<a href="https://github.com/golang/go/issues" class="Footer-link">
Issue Tracker
</a>
<a href="https://golang.org/doc/devel/release.html" class="Footer-link">
Release Notes
</a>
<a href="https://blog.golang.org/go-brand" class="Footer-link">
Brand Guidelines
</a>
<a href="https://golang.org/conduct" class="Footer-link">
Code of Conduct
</a>
</div>
<div class="Footer-linkColumn">
<a href="https://www.twitter.com/golang" class="Footer-link Footer-link--primary">
Connect
</a>
<a href="https://www.twitter.com/golang" class="Footer-link">
Twitter
</a>
<a href="https://github.com/golang" class="Footer-link">
GitHub
</a>
<a href="https://invite.slack.golangbridge.org/" class="Footer-link">
Slack
</a>
<a href="https://reddit.com/r/golang" class="Footer-link">
r/golang
</a>
<a href="https://www.meetup.com/pro/go" class="Footer-link">
Meetup
</a>
<a href="https://golangweekly.com/" class="Footer-link">
Golang Weekly
</a>
</div>
</div>
</div>
</div>
<div class="Footer">
<div class="Container Container--fullBleed">
<div class="Footer-bottom">
<img class="Footer-gopher" src="/images/gophers/pilot-bust.svg" alt="The Go Gopher">
<ul class="Footer-listRow">
<li class="Footer-listItem">
<a href="/copyright">Copyright</a>
</li>
<li class="Footer-listItem">
<a href="/tos">Terms of Service</a>
</li>
<li class="Footer-listItem">
<a href="http://www.google.com/intl/en/policies/privacy/"
target="_blank"
rel="noopener">
Privacy Policy
</a>
</li>
<li class="Footer-listItem">
<a
href="https://golang.org/s/discovery-feedback"
target="_blank"
rel="noopener"
>
Report an Issue
</a>
</li>
<li class="Footer-listItem">
<a
href="https://golang.org"
target="_blank"
rel="noopener"
>golang.org
</a>
</li>
</ul>
<a class="Footer-googleLogo" target="_blank" href="https://google.com" rel="noopener">
<img class="Footer-googleLogoImg" src="/images/google-white.png" alt="Google logo">
</a>
</div>
</div>
</div>
<script src="/js/carousels.js"></script>
<script src="/js/searchBox.js"></script>
<script src="/js/misc.js"></script>
<script src="/js/hats.js"></script>
</footer>
</body>
</html>