Skip to content

Commit

Permalink
cmd/golangorg, content: serve /doc from content/static/doc before GOR…
Browse files Browse the repository at this point in the history
…OOT/doc

In the "/doc" directory, files are now served from the
content/static/doc, then from GOROOT/doc (where GOROOT is either a zip
file or the GOROOT directory).

This allows documentation to be moved to golang.org outside of the
normal Go release cycle. For example, this CL moves (but does not
modify) doc/docs.html here. Documentation that is tied to the Go
release cycle (for example, doc/spec.html) will not be moved.

Updates golang/go#33637
Updates golang/go#29206

Change-Id: I5f1c577e0ffddc3418653bdd9b0cc36cf79e3fe1
Reviewed-on: https://go-review.googlesource.com/c/website/+/197638
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
  • Loading branch information
Jay Conrod committed Sep 30, 2019
1 parent 07c3481 commit efeb149
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 18 deletions.
9 changes: 5 additions & 4 deletions cmd/golangorg/appinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ func main() {
fs.Bind("/", rootfs, "/", vfs.BindReplace)
}

// Use a local copy of root.html instead of the one in the main go repository.
// See golang.org/issue/29206 for more info.
fs.Bind("/doc/root.html", mapfs.New(static.Files), "/doc/root.html", vfs.BindReplace)
fs.Bind("/doc/copyright.html", mapfs.New(static.Files), "/doc/copyright.html", vfs.BindReplace)
// Try serving files in /doc from a local copy before trying the main
// go repository. This lets us update some documentation outside the
// Go release cycle. This includes root.html, which redirects to "/".
// See golang.org/issue/29206.
fs.Bind("/doc", mapfs.New(static.Files), "/doc", vfs.BindBefore)
fs.Bind("/lib/godoc", mapfs.New(static.Files), "/", vfs.BindReplace)

webroot := getFullPath("/src/golang.org/x/website")
Expand Down
18 changes: 9 additions & 9 deletions cmd/golangorg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
// Web server tree:
//
// https://golang.org/ main landing page
// https://golang.org/doc/ serve from $GOROOT/doc - spec, mem, etc.
// https://golang.org/doc/ serve from content/static/doc, then $GOROOT/doc. spec, mem, etc.
// https://golang.org/src/ serve files from $GOROOT/src; .go gets pretty-printed
// https://golang.org/cmd/ serve documentation about commands
// https://golang.org/pkg/ serve documentation about packages
// (idea is if you say import "compress/zlib", you go to
// https://golang.org/pkg/compress/zlib)
//

// Some pages are being transitioned from $GOROOT to this source tree.
// See bindings below to see which ones.
// Some pages are being transitioned from $GOROOT to content/static/doc.
// See golang.org/issue/29206 and golang.org/issue/33637.

// +build !golangorg

Expand Down Expand Up @@ -143,15 +143,15 @@ func main() {
defer rc.Close() // be nice (e.g., -writeIndex mode)
fs.Bind("/", zipfs.New(rc, *zipfile), *goroot, vfs.BindReplace)
}
// Use a local copy of root.html instead of the one in the main go repository.
// See golang.org/issue/29206 for more info.
// Try serving files in /doc from a local copy before trying the main
// go repository. This lets us update some documentation outside the
// Go release cycle. This includes root.html, which redirects to "/".
// See golang.org/issue/29206.
if *templateDir != "" {
fs.Bind("/doc/root.html", vfs.OS(*templateDir), "/doc/root.html", vfs.BindReplace)
fs.Bind("/doc/copyright.html", vfs.OS(*templateDir), "/doc/copyright.html", vfs.BindReplace)
fs.Bind("/doc", vfs.OS(*templateDir), "/doc", vfs.BindBefore)
fs.Bind("/lib/godoc", vfs.OS(*templateDir), "/", vfs.BindBefore)
} else {
fs.Bind("/doc/root.html", mapfs.New(static.Files), "/doc/root.html", vfs.BindReplace)
fs.Bind("/doc/copyright.html", mapfs.New(static.Files), "/doc/copyright.html", vfs.BindReplace)
fs.Bind("/doc", mapfs.New(static.Files), "/doc", vfs.BindBefore)
fs.Bind("/lib/godoc", mapfs.New(static.Files), "/", vfs.BindReplace)
}

Expand Down
232 changes: 232 additions & 0 deletions content/static/doc/docs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
<!--{
"Title": "Documentation",
"Path": "/doc/",
"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>Installing Go</h2>

<h3><a href="/doc/install">Getting Started</a></h3>
<p>
Instructions for downloading and installing the Go compilers, tools, and
libraries.
</p>


<h2 id="learning">Learning Go</h2>

<img class="gopher" src="/doc/gopher/doc.png"/>

<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>

<h3 id="code"><a href="code.html">How to write Go code</a></h3>
<p>
{{if not $.GoogleCN}}
Also available as a <a href="//www.youtube.com/watch?v=XCsL89YtqCs">screencast</a>, this
{{else}}
This
{{end}}
doc explains how to use the <a href="/cmd/go/">go command</a>
to fetch, build, and install packages, commands, and run tests.
</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="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="diagnostics"><a href="/doc/diagnostics.html">Diagnostics</a></h3>
<p>
Summarizes tools and methodologies to diagnose problems in Go programs.
</p>

<h3 id="faq"><a href="/doc/faq">Frequently Asked Questions (FAQ)</a></h3>
<p>
Answers to common questions about Go.
</p>

<h3 id="wiki"><a href="/wiki">The Go Wiki</a></h3>
<p>A wiki maintained by the Go community.</p>

<h4 id="learn_more">More</h4>
<p>
See the <a href="/wiki/Learn">Learn</a> page at the <a href="/wiki">Wiki</a>
for more Go learning resources.
</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="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="articles">Articles</h2>

{{if not $.GoogleCN}}
<h3 id="blog"><a href="//blog.golang.org/">The Go Blog</a></h3>
<p>The official blog of the Go project, featuring news and in-depth articles by
the Go team and guests.</p>
{{end}}

<h4>Codewalks</h4>
<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>
<li><a href="/doc/articles/wiki/">Writing Web Applications</a> - building a simple web application.</li>
</ul>

{{if not $.GoogleCN}}
<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>
{{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>

<h4 id="articles_more">More</h4>
<p>
See the <a href="/wiki/Articles">Articles page</a> at the
<a href="/wiki">Wiki</a> for more Go articles.
</p>

{{if not $.GoogleCN}}
<h2 id="talks">Talks</h2>

<img class="gopher" src="/doc/gopher/talks.png"/>

<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>
1 change: 1 addition & 0 deletions content/static/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var files = []string{
"codewalkdir.html",
"dirlist.html",
"doc/copyright.html",
"doc/docs.html",
"doc/root.html",
"error.html",
"example.html",
Expand Down
Loading

0 comments on commit efeb149

Please sign in to comment.