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 <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Cameron Balahan <cbalahan@google.com>
diff --git a/README.md b/README.md index 253a18f..88aa3ed 100644 --- a/README.md +++ b/README.md
@@ -37,6 +37,21 @@ * Conversion between string and []rune * Table-driven unit tests ([testing](//golang.org/pkg/testing/)) +## [helloserver](helloserver/) + +``` +$ cd helloserver +$ go run . +``` + +A trivial "Hello, world" web server. + +Topics covered: + +* Command-line flags ([flag](//golang.org/pkg/flag/)) +* Logging ([log](//golang.org/pkg/log/)) +* Web servers ([net/http](//golang.org/pkg/net/http/)) + ## [outyet](outyet/) ```
diff --git a/outyet/Dockerfile b/outyet/Dockerfile deleted file mode 100644 index 3fa58ff..0000000 --- a/outyet/Dockerfile +++ /dev/null
@@ -1,2 +0,0 @@ -FROM golang:onbuild -EXPOSE 8080
diff --git a/outyet/containers.yaml b/outyet/containers.yaml deleted file mode 100644 index 44ba78a..0000000 --- a/outyet/containers.yaml +++ /dev/null
@@ -1,8 +0,0 @@ -version: v1beta2 -containers: -- name: outyet - image: adg1/outyet - ports: - - name: http - hostPort: 80 - containerPort: 8080
diff --git a/outyet/go.mod b/outyet/go.mod new file mode 100644 index 0000000..720bbb4 --- /dev/null +++ b/outyet/go.mod
@@ -0,0 +1,4 @@ +module golang.org/x/example/outyet + +go 1.19 +
diff --git a/outyet/main.go b/outyet/main.go index ab251ba..496af2c 100644 --- a/outyet/main.go +++ b/outyet/main.go
@@ -19,7 +19,7 @@ // Command-line flags. var ( - httpAddr = flag.String("http", ":8080", "Listen address") + httpAddr = flag.String("http", "localhost:8080", "Listen address") pollPeriod = flag.Duration("poll", 5*time.Second, "Poll period") version = flag.String("version", "1.4", "Go version") ) @@ -30,6 +30,7 @@ flag.Parse() changeURL := fmt.Sprintf("%sgo%s", baseChangeURL, *version) http.Handle("/", NewServer(*version, changeURL, *pollPeriod)) + log.Printf("serving http://%s", *httpAddr) log.Fatal(http.ListenAndServe(*httpAddr, nil)) }