diff --git a/README.md b/README.md index 253a18f0..88aa3ed2 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,21 @@ The [reverse](hello/reverse/) reverse covers: * 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 3fa58ff7..00000000 --- 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 44ba78a6..00000000 --- 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 00000000..720bbb4d --- /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 ab251baa..496af2c1 100644 --- a/outyet/main.go +++ b/outyet/main.go @@ -19,7 +19,7 @@ import ( // 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 @@ func main() { 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)) }