Commit a220dfa9 authored by barnettZQG's avatar barnettZQG

init

parents
Pipeline #682 failed with stages
{
"go.inferGopath": false
}
\ No newline at end of file
module goodrain.com/api-load
go 1.15
require github.com/sirupsen/logrus v1.7.0 // indirect
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
package main
import (
"net/http"
"os"
"strconv"
"time"
"github.com/sirupsen/logrus"
)
func main() {
var sleep = os.Getenv("SLEEP")
sleepInt, _ := strconv.Atoi(sleep)
if sleepInt == 0 {
sleepInt = 3
}
var i = 0
http.HandleFunc("/api", func(rw http.ResponseWriter, r *http.Request) {
time.Sleep(time.Millisecond * time.Duration(sleepInt))
logrus.Infof("receive request %d", i)
rw.Write([]byte("Hello word"))
i++
})
logrus.Info("server listen")
http.ListenAndServe(":9000", nil)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment