diff options
author | Russ Cox <rsc@golang.org> | 2020-03-15 15:50:36 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2020-03-17 20:58:46 +0000 |
commit | 972d42d925e6cae3f8eebd9b21d445e06c2eb386 (patch) | |
tree | 737af27f0d49318b612efec874b1d1328c699d1a /content/maps | |
parent | faf1e2da2d911edc717993e8edb24fe88f99b2b5 (diff) |
content: rename articles to reinforce convention of short URLs
The Go blog started out on Blogger
(http://web.archive.org/web/20100325005843/http://blog.golang.org/).
Later, we moved to the current self-hosted blog server
with extra Go-specific functionality like playground snippets.
The old Blogger posts have very long URLs that Blogger chose
for us, such as "go-programming-language-turns-two" or
"two-go-talks-lexical-scanning-in-go-and", predating
the convention of giving posts shorter, more share-friendly,
typeable names.
The conversion of the old Blogger posts also predated
the convention of putting supporting files in a subdirectory.
The result is that although we've established new conventions,
you wouldn't know by listing the directory - the old Blogger
content presents a conflicting picture.
This commit renames the posts with very long names
to have shorter, more share-friendly names, and it moves
all supporting files to subdirectories. It also adds a README
documenting the conventions.
For example, blog.golang.org/go-programming-language-turns-two
is now blog.golang.org/2years, matching our more recent birthday
post URLs, and its supporting files are moved to the new 2years/ directory.
The old URLs redirect to the new ones.
Change-Id: I9f46a790c2c8fab8459aeda73d4e3d2efc86d88f
Reviewed-on: https://go-review.googlesource.com/c/blog/+/223599
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Diffstat (limited to 'content/maps')
-rw-r--r-- | content/maps/list.go | 29 | ||||
-rw-r--r-- | content/maps/people.go | 34 |
2 files changed, 63 insertions, 0 deletions
diff --git a/content/maps/list.go b/content/maps/list.go new file mode 100644 index 0000000..02bea2c --- /dev/null +++ b/content/maps/list.go @@ -0,0 +1,29 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build OMIT + +package main + +import "fmt" + +func main() { + // START OMIT + type Node struct { + Next *Node + Value interface{} + } + var first *Node + + visited := make(map[*Node]bool) // HL + for n := first; n != nil; n = n.Next { + if visited[n] { // HL + fmt.Println("cycle detected") + break + } + visited[n] = true // HL + fmt.Println(n.Value) + } + // END OMIT +} diff --git a/content/maps/people.go b/content/maps/people.go new file mode 100644 index 0000000..ff5d9e3 --- /dev/null +++ b/content/maps/people.go @@ -0,0 +1,34 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build OMIT + +package main + +import "fmt" + +func main() { + // START1 OMIT + type Person struct { + Name string + Likes []string + } + var people []*Person + + likes := make(map[string][]*Person) // HL + for _, p := range people { + for _, l := range p.Likes { + likes[l] = append(likes[l], p) // HL + } + } + // END1 OMIT + + // START2 OMIT + for _, p := range likes["cheese"] { + fmt.Println(p.Name, "likes cheese.") + } + // END2 OMIT + + fmt.Println(len(likes["bacon"]), "people like bacon.") +} |