From 94f852584ceec9d223305977eacb273be42d1501 Mon Sep 17 00:00:00 2001 From: abeltay Date: Fri, 8 Dec 2017 17:24:23 +0800 Subject: [PATCH] Move example code to README (#5) The code exampleServer.go was added so that dep can correctly identify this repo as a Go repo. However, the file is not really used and the example code is better put into the README as a reference. This is replaced with a file named dep.go and a comment explaining the purpose of the file. --- README.md | 19 +++++++++++++++++++ dep.go | 2 ++ exampleServer.go | 17 ----------------- 3 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 dep.go delete mode 100644 exampleServer.go diff --git a/README.md b/README.md index da0793e..bc3183b 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,23 @@ Cryptographically random strings to be used for things like session IDs. ## Server Starts a HTTP server with graceful shutdown when receiving `SIGINT` or `SIGTERM` +Example code: +``` +import ( + "log" + "time" + + "github.com/moexmen/gokit/web" +) + +func main() { + s := web.Server{ + Addr: ":8080", + Timeout: 5 * time.Second, + } + log.Println("Starting...") + log.Println(s.ListenAndServe()) +} +``` + [Docker Stop](https://docs.docker.com/compose/reference/stop/) has a default timeout of 10 seconds. We recommend to use a timeout lower than 10 seconds if you use Docker. diff --git a/dep.go b/dep.go new file mode 100644 index 0000000..a74861b --- /dev/null +++ b/dep.go @@ -0,0 +1,2 @@ +// This file is used to ensure that dep correctly identifies this as a Go repository. +package main diff --git a/exampleServer.go b/exampleServer.go deleted file mode 100644 index 8edef11..0000000 --- a/exampleServer.go +++ /dev/null @@ -1,17 +0,0 @@ -package main - -import ( - "log" - "time" - - "github.com/moexmen/gokit/web" -) - -func main() { - s := web.Server{ - Addr: ":8080", - Timeout: 5 * time.Second, - } - log.Println("Starting...") - log.Println(s.ListenAndServe()) -}