Skip to content

Commit 0c9b5c5

Browse files
rscgopherbot
authored andcommitted
outyet: update example, make a separate module
We want to revive golang.org/x/example as a test case for an experiment with a 'gonew' command. This CL updates outyet to be a gonew-able sample server, by making it its own module. The CL also removes Dockerfile and containers.yaml because I think the best practices around those files have evolved too much since 2015 when they were written. Change-Id: I53faf4b30de9e4ef3bfe35a781732daa140a9877 Reviewed-on: https://go-review.googlesource.com/c/example/+/513998 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Russ Cox <[email protected]> Auto-Submit: Russ Cox <[email protected]> Reviewed-by: Cameron Balahan <[email protected]>
1 parent 3dc2413 commit 0c9b5c5

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ The [reverse](hello/reverse/) reverse covers:
3737
* Conversion between string and []rune
3838
* Table-driven unit tests ([testing](//golang.org/pkg/testing/))
3939

40+
## [helloserver](helloserver/)
41+
42+
```
43+
$ cd helloserver
44+
$ go run .
45+
```
46+
47+
A trivial "Hello, world" web server.
48+
49+
Topics covered:
50+
51+
* Command-line flags ([flag](//golang.org/pkg/flag/))
52+
* Logging ([log](//golang.org/pkg/log/))
53+
* Web servers ([net/http](//golang.org/pkg/net/http/))
54+
4055
## [outyet](outyet/)
4156

4257
```

outyet/Dockerfile

-2
This file was deleted.

outyet/containers.yaml

-8
This file was deleted.

outyet/go.mod

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module golang.org/x/example/outyet
2+
3+
go 1.19
4+

outyet/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
// Command-line flags.
2121
var (
22-
httpAddr = flag.String("http", ":8080", "Listen address")
22+
httpAddr = flag.String("http", "localhost:8080", "Listen address")
2323
pollPeriod = flag.Duration("poll", 5*time.Second, "Poll period")
2424
version = flag.String("version", "1.4", "Go version")
2525
)
@@ -30,6 +30,7 @@ func main() {
3030
flag.Parse()
3131
changeURL := fmt.Sprintf("%sgo%s", baseChangeURL, *version)
3232
http.Handle("/", NewServer(*version, changeURL, *pollPeriod))
33+
log.Printf("serving http://%s", *httpAddr)
3334
log.Fatal(http.ListenAndServe(*httpAddr, nil))
3435
}
3536

0 commit comments

Comments
 (0)