1
0
Fork 0
master
Ambrose Chua 2017-12-02 00:24:03 +08:00
parent bcbeb34e09
commit 70562aac4c
2 changed files with 10 additions and 4 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
hello-world

View File

@ -4,17 +4,22 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"os" "os"
"runtime"
"time" "time"
) )
func handler(w http.ResponseWriter, r *http.Request) { func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello world! Here's some info:\n\n") fmt.Fprintf(w, "Hello world! Here's some info:\n\n")
time, _ := time.Now() time := time.Now()
numCPU := runtime.NumCPU()
version := runtime.Version()
hostname, _ := os.Hostname() hostname, _ := os.Hostname()
environ, _ := os.Environ() environ := os.Environ()
uid, _ := os.Getuid() uid := os.Getuid()
gid, _ := os.Getgid() gid := os.Getgid()
fmt.Fprintf(w, "Time: %v", time) fmt.Fprintf(w, "Time: %v", time)
fmt.Fprintf(w, "CPUs: %v", numCPU)
fmt.Fprintf(w, "Go version: %v", version)
fmt.Fprintf(w, "Hostname: %v\n", hostname) fmt.Fprintf(w, "Hostname: %v\n", hostname)
fmt.Fprintf(w, "Environment: %v\n", environ) fmt.Fprintf(w, "Environment: %v\n", environ)
fmt.Fprintf(w, "UID: %v GID: %v\n", uid, gid) fmt.Fprintf(w, "UID: %v GID: %v\n", uid, gid)