This commit is contained in:
lwl0608 2024-05-17 11:32:31 +08:00
parent f7e6a6f6b7
commit ae6679be06
4 changed files with 48 additions and 1 deletions

View File

@ -12,8 +12,10 @@ func main() {
var host string
var port int
flag.StringVar(&host, "h", GetIp(), "IP地址")
flag.IntVar(&port, "p", 9000, "端口")
flag.IntVar(&port, "p", 12564, "端口")
flag.Parse()
fmt.Println(host)
address := fmt.Sprintf("%s:%d", host, port)
http.HandleFunc("/ping", func(writer http.ResponseWriter, request *http.Request) {
_, _ = fmt.Fprintln(writer, fmt.Sprintf("%s by %s", "pong", address))

BIN
sig/sig Executable file

Binary file not shown.

16
sig/sig.go Normal file
View File

@ -0,0 +1,16 @@
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
quit := make(chan os.Signal)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
fmt.Println("Shutdown")
}

29
test/mai.go Normal file
View File

@ -0,0 +1,29 @@
package main
import (
"fmt"
"io/ioutil"
"net/http"
"time"
)
func loop() {
resp, err := http.Get("http://nginx-server.tiefen.fun")
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
fmt.Println(string(data))
}
func main() {
for range time.Tick(time.Millisecond * 500) {
loop()
}
}