README.md: update package paths to be golang.org/x/example/...
The module name is golang.org/x/example and the canonical repo
is go.googlesource.com/example.
Add the pkg.go.dev link in the main README.md and remove
stale godoc.org links.
Change-Id: Ia67be2179885d144c97284237df1f4373717722d
Reviewed-on: https://go-review.googlesource.com/c/example/+/307689
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
diff --git a/README.md b/README.md
index 28c5e94..72072d6 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,14 @@
# Go example projects
+
+[![Go Reference](https://pkg.go.dev/badge/golang.org/x/example.svg)](https://pkg.go.dev/golang.org/x/example)
+
This repository contains a collection of Go programs and libraries that
demonstrate the language, standard libraries, and tools.
-## The examples
+## [hello](hello/) and [stringutil](stringutil/)
-### [hello](hello/) ([godoc](//godoc.org/github.com/golang/example/hello)) and [stringutil](stringutil/) ([godoc](//godoc.org/github.com/golang/example/stringutil))
-
- go get github.com/golang/example/hello
+ go get golang.org/x/example/hello
A trivial "Hello, world" program that uses a stringutil package.
@@ -23,9 +24,9 @@
* Conversion between string and []rune
* Table-driven unit tests ([testing](//golang.org/pkg/testing/))
-### [outyet](outyet/) ([godoc](//godoc.org/github.com/golang/example/outyet))
+## [outyet](outyet/)
- go get github.com/golang/example/outyet
+ go get golang.org/x/example/outyet
A web server that answers the question: "Is Go 1.x out yet?"
@@ -42,16 +43,16 @@
* Dependency injection
* Time ([time](//golang.org/pkg/time/))
-### [appengine-hello](appengine-hello/) ([godoc](//godoc.org/github.com/golang/example/appengine-hello))
+## [appengine-hello](appengine-hello/)
- goapp get github.com/golang/example/appengine-hello
+ goapp get golang.org/x/example/appengine-hello
A trivial "Hello, world" App Engine application intended to be used as the
starting point for your own code.
_Note_: The `goapp` tool is part of the [Google App Engine SDK for Go](https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_Go).
-### [gotypes](gotypes/) ([godoc](//godoc.org/github.com/golang/example/gotypes))
+## [gotypes](gotypes/)
The `go/types` package is a type-checker for Go programs. It is one of the most
complex packages in Go's standard library, so we have provided this tutorial to
@@ -59,7 +60,7 @@
can obtain using `go get` and play with as you learn to build tools that analyze
or manipulate Go programs.
-### [template](template/) ([godoc](//godoc.org/github.com/golang/example/template))
+## [template](template/)
A trivial web server that demonstrates the use of the
[`template` package](https://golang.org/pkg/text/template/)'s `block` feature.
diff --git a/gotypes/README.md b/gotypes/README.md
index a235fc8..e6883f5 100644
--- a/gotypes/README.md
+++ b/gotypes/README.md
@@ -78,7 +78,7 @@
-The [`golang.org/x/tools/go/loader` package](https://godoc.org/golang.org/x/tools/go/loader)
+The [`golang.org/x/tools/go/loader` package](https://pkg.go.dev/golang.org/x/tools/go/loader)
from the `x/tools` repository is a client of the type
checker that loads, parses, and type-checks a complete Go program from
source code.
@@ -133,10 +133,10 @@
Later examples will be variations on this one, and we'll often omit
boilerplate details such as parsing.
To check out and build the examples,
-run `go get github.com/golang/example/gotypes/...`.
+run `go get golang.org/x/example/gotypes/...`.
- // go get github.com/golang/example/gotypes/pkginfo
+ // go get golang.org/x/example/gotypes/pkginfo
```
package main
@@ -243,7 +243,7 @@
```
-$ go build github.com/golang/example/gotypes/pkginfo
+$ go build golang.org/x/example/gotypes/pkginfo
$ ./pkginfo
Package "cmd/hello"
Name: main
@@ -492,7 +492,7 @@
identifier in the input program, and the object it refers to.
- // go get github.com/golang/example/gotypes/defsuses
+ // go get golang.org/x/example/gotypes/defsuses
```
func PrintDefsUses(fset *token.FileSet, files ...*ast.File) error {
@@ -522,7 +522,7 @@
Let's use the _hello, world_ program again as the input:
- // go get github.com/golang/example/gotypes/hello
+ // go get golang.org/x/example/gotypes/hello
```
package main
@@ -539,7 +539,7 @@
```
-$ go build github.com/golang/example/gotypes/defsuses
+$ go build golang.org/x/example/gotypes/defsuses
$ ./defsuses
hello.go:1:9: "main" defines <nil>
hello.go:5:6: "main" defines func hello.main()
@@ -783,7 +783,7 @@
preserve comments in the input.
- // go get github.com/golang/example/gotypes/lookup
+ // go get golang.org/x/example/gotypes/lookup
```
func main() {
@@ -853,7 +853,7 @@
```
-$ go build github.com/golang/example/gotypes/lookup
+$ go build golang.org/x/example/gotypes/lookup
$ ./lookup
At hello.go:6:1, "append" = builtin append
At hello.go:8:9, "fmt" = package fmt
@@ -1467,7 +1467,7 @@
type-checked file and prints its type, value, and mode:
- // go get github.com/golang/example/gotypes/typeandvalue
+ // go get golang.org/x/example/gotypes/typeandvalue
```
// f is a parsed, type-checked *ast.File.
@@ -1517,7 +1517,7 @@
```
-$ go build github.com/golang/example/gotypes/typeandvalue
+$ go build golang.org/x/example/gotypes/typeandvalue
$ ./typeandvalue
make(map[string]int) mode: value
type: map[string]int
@@ -1573,7 +1573,7 @@
comparing a method `x.f` against nil is a common mistake.
- // go get github.com/golang/example/gotypes/nilfunc
+ // go get golang.org/x/example/gotypes/nilfunc
```
// CheckNilFuncComparison reports unintended comparisons
@@ -1640,7 +1640,7 @@
```
-$ go build github.com/golang/example/gotypes/nilfunc
+$ go build golang.org/x/example/gotypes/nilfunc
$ ./nilfunc
input.go:7:5: comparison of function Bytes == nil is always false
input.go:7:25: comparison of function Repeat != nil is always true
@@ -1894,7 +1894,7 @@
calls `PrintSkeleton` with the remaining two arguments:
- // go get github.com/golang/example/gotypes/skeleton
+ // go get golang.org/x/example/gotypes/skeleton
```
func PrintSkeleton(pkg *types.Package, ifacename, concname string) error {
@@ -1968,7 +1968,7 @@
in `pkg`, and reports the types that satisfy each interface type.
- // go get github.com/golang/example/gotypes/implements
+ // go get golang.org/x/example/gotypes/implements
```
// Find all named types at package level.
@@ -2000,7 +2000,7 @@
Given this input,
- // go get github.com/golang/example/gotypes/implements
+ // go get golang.org/x/example/gotypes/implements
```
const input = `package main
@@ -2022,7 +2022,7 @@
```
-$ go build github.com/golang/example/gotypes/implements
+$ go build golang.org/x/example/gotypes/implements
$ ./implements
*hello.A satisfies hello.I
hello.B satisfies hello.I
@@ -2177,7 +2177,7 @@
programs.
- // go get github.com/golang/example/gotypes/hugeparam
+ // go get golang.org/x/example/gotypes/hugeparam
```
var bytesFlag = flag.Int("bytes", 48, "maximum parameter size in bytes")
@@ -2336,7 +2336,7 @@
program starting from the single package, `pkgpath`:
- // go get github.com/golang/example/gotypes/doc
+ // go get golang.org/x/example/gotypes/doc
```
pkgpath, name := os.Args[1], os.Args[2]
@@ -2362,7 +2362,7 @@
The rest of the program prints the output:
- // go get github.com/golang/example/gotypes/doc
+ // go get golang.org/x/example/gotypes/doc
```
// Print the object and its methods (incl. location of definition).
diff --git a/gotypes/weave.go b/gotypes/weave.go
index 770bda2..cfaa57b 100644
--- a/gotypes/weave.go
+++ b/gotypes/weave.go
@@ -77,7 +77,7 @@
// Show caption unless '-' follows.
if len(words) < 4 || words[3] != "-" {
- fmt.Printf(" // go get github.com/golang/example/gotypes/%s\n\n",
+ fmt.Printf(" // go get golang.org/x/example/gotypes/%s\n\n",
filepath.Dir(filename))
}