Skip to content

Commit

Permalink
README.md: update package paths to be golang.org/x/example/...
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
HadesHappy committed Apr 7, 2021
1 parent 7c3d7b9 commit 2b7946d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/) ([godoc](//godoc.org/github.com/golang/example/hello)) and [stringutil](stringutil/) ([godoc](//godoc.org/github.com/golang/example/stringutil))
## [hello](hello/) and [stringutil](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.

Expand All @@ -23,9 +24,9 @@ Library [stringutil](stringutil/) covers:
* 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?"

Expand All @@ -42,24 +43,24 @@ Topics covered:
* 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
help you find your bearings. It comes with several example programs that you
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.
40 changes: 20 additions & 20 deletions gotypes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ constant expressions, as we'll see in



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.
Expand Down Expand Up @@ -133,10 +133,10 @@ the _hello, world_ program, supplied as a string.
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
Expand Down Expand Up @@ -243,7 +243,7 @@ Finally, the program prints the attributes of the package, shown below.


```
$ go build github.com/golang/example/gotypes/pkginfo
$ go build golang.org/x/example/gotypes/pkginfo
$ ./pkginfo
Package "cmd/hello"
Name: main
Expand Down Expand Up @@ -492,7 +492,7 @@ The function below prints the location of each referring and defining
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 {
Expand Down Expand Up @@ -522,7 +522,7 @@ func PrintDefsUses(fset *token.FileSet, files ...*ast.File) error {
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
Expand All @@ -539,7 +539,7 @@ This is what it prints:


```
$ 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()
Expand Down Expand Up @@ -783,7 +783,7 @@ Observe that the `ParseComments` flag directs the parser to
preserve comments in the input.


// go get github.com/golang/example/gotypes/lookup
// go get golang.org/x/example/gotypes/lookup

```
func main() {
Expand Down Expand Up @@ -853,7 +853,7 @@ Here's the output:


```
$ 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
Expand Down Expand Up @@ -1467,7 +1467,7 @@ The statement below inspects every expression within the AST of a single
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.
Expand Down Expand Up @@ -1517,7 +1517,7 @@ the program prints:


```
$ 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
Expand Down Expand Up @@ -1573,7 +1573,7 @@ call `x.f()` was intended;
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
Expand Down Expand Up @@ -1640,7 +1640,7 @@ the program reports these errors:


```
$ 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
Expand Down Expand Up @@ -1894,7 +1894,7 @@ The `main` function (not shown) loads the specified package and
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 {
Expand Down Expand Up @@ -1968,7 +1968,7 @@ The following program inspects all pairs of package-level named types
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.
Expand Down Expand Up @@ -2000,7 +2000,7 @@ for _, T := range allNamed {
Given this input,


// go get github.com/golang/example/gotypes/implements
// go get golang.org/x/example/gotypes/implements

```
const input = `package main
Expand All @@ -2022,7 +2022,7 @@ the program prints:


```
$ 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
Expand Down Expand Up @@ -2177,7 +2177,7 @@ Such a tool could help identify inefficient parameter passing in your
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")
Expand Down Expand Up @@ -2336,7 +2336,7 @@ Here's the first part of the program, showing how to load an entire
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]
Expand All @@ -2362,7 +2362,7 @@ Notice that we instructed the parser to retain comments during parsing.
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).
Expand Down
2 changes: 1 addition & 1 deletion gotypes/weave.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func main() {

// 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))
}

Expand Down

0 comments on commit 2b7946d

Please sign in to comment.