hhu67 vor 1 Woche
Ursprung
Commit
54d6175318
3 geänderte Dateien mit 35 neuen und 1 gelöschten Zeilen
  1. 1 0
      .gitignore
  2. 34 0
      go/l19/l2.go
  3. 0 1
      go/output/go_build_my_app

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 .vscode
 .vscode
 .env
 .env
 .idea
 .idea
+go_build_my_app

+ 34 - 0
go/l19/l2.go

@@ -0,0 +1,34 @@
+package main
+
+import (
+	"fmt"
+	"net/http"
+	"encoding/json"
+	"time"
+	"bytes"
+	"io"
+)
+
+type UserStruct struct{
+	Age int `json:"age"`
+	Name string `json:"name"`
+	Email string `json:"email"`
+}
+
+func main() {
+	user := UserStruct{
+		Age: 66,
+		Name: "Sergey",
+		Email: "Likhodeev.60@mail.ru"
+	}
+	JsonData, err := json.Marshal(user)
+	if err != nil {
+		panic(err)
+	}
+	client := &http.Client(
+		Timeout: 5 * time.Second,
+	)
+	req, err := http.NewRequest("POST", "http://127.0.0.1:7777/user", bytes.NewBuffer(JsonData))
+	if err != nil {
+		panic(err)
+	}

+ 0 - 1
go/output/go_build_my_app

@@ -1 +0,0 @@
-ELF