зеркало из https://github.com/golang/example.git
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>
This commit is contained in:
Родитель
3dc2413024
Коммит
0c9b5c54f5
15
README.md
15
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/)
|
||||
|
||||
```
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
FROM golang:onbuild
|
||||
EXPOSE 8080
|
|
@ -1,8 +0,0 @@
|
|||
version: v1beta2
|
||||
containers:
|
||||
- name: outyet
|
||||
image: adg1/outyet
|
||||
ports:
|
||||
- name: http
|
||||
hostPort: 80
|
||||
containerPort: 8080
|
|
@ -0,0 +1,4 @@
|
|||
module golang.org/x/example/outyet
|
||||
|
||||
go 1.19
|
||||
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче