Skip to content

Commit 7de01b2

Browse files
committed
Removing go.mod and go.sum from subdirectories and updating gitignore
1 parent 491ebbf commit 7de01b2

File tree

21 files changed

+877
-880
lines changed

21 files changed

+877
-880
lines changed
+56-56
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
package main
22

3-
import (
4-
"net/http"
5-
6-
"github.com/labstack/echo/v4"
7-
)
8-
9-
// Struct representing a user model
10-
type My struct {
11-
ID string `json:"id"`
12-
Name string `json:"name"`
13-
Year int `json:"year"`
14-
Price float64 `json:"price"`
15-
Big bool `json:"big"`
16-
Car bool `json:"car"`
17-
Tags []string `json:"tags"`
18-
Metadata map[string]interface{} `json:"metadata"`
19-
Options []Option `json:"options"`
20-
Extra interface{} `json:"extra"`
21-
Dynamic map[string]interface{} `json:"dynamic"`
22-
}
23-
24-
// Struct representing an option with a key-value pair
25-
type Option struct {
26-
Key string `json:"key"`
27-
Value string `json:"value"`
28-
}
29-
30-
// curl --location 'http://localhost:8080/v1/user' \
31-
// --header 'Content-Type: application/json' \
32-
// --data '[{"id": "123", "name": "Alice", "year": 20,
33-
// "price": 100.5, "big": true, "car": false, "tags": ["fast", "blue"],
34-
// "metadata": {"brand": "Tesla"}, "options": [{"key": "color", "value": "red"}],
35-
// "extra": "some data", "dynamic": {"speed": "200km/h"}}]'
36-
func main() {
37-
// Create a new Echo instance
38-
e := echo.New()
39-
40-
// Define a POST route at /v1/user
41-
e.POST("/v1/user", func(c echo.Context) error {
42-
c.Set("Content-type", "application/json")
43-
44-
var my []My // Slice to store multiple user objects
45-
46-
// Bind the incoming JSON payload to the 'my' slice
47-
if err := c.Bind(&my); err != nil {
48-
// Return a Bad Request response if binding fails
49-
return c.String(http.StatusBadRequest, err.Error())
50-
}
51-
52-
// Return the parsed JSON as a response
53-
return c.JSON(http.StatusOK, my)
54-
})
55-
56-
// Start the Echo server on port 8080
57-
e.Start(":8080")
58-
}
3+
// import (
4+
// "net/http"
5+
6+
// "github.com/labstack/echo/v4"
7+
// )
8+
9+
// // Struct representing a user model
10+
// type My struct {
11+
// ID string `json:"id"`
12+
// Name string `json:"name"`
13+
// Year int `json:"year"`
14+
// Price float64 `json:"price"`
15+
// Big bool `json:"big"`
16+
// Car bool `json:"car"`
17+
// Tags []string `json:"tags"`
18+
// Metadata map[string]interface{} `json:"metadata"`
19+
// Options []Option `json:"options"`
20+
// Extra interface{} `json:"extra"`
21+
// Dynamic map[string]interface{} `json:"dynamic"`
22+
// }
23+
24+
// // Struct representing an option with a key-value pair
25+
// type Option struct {
26+
// Key string `json:"key"`
27+
// Value string `json:"value"`
28+
// }
29+
30+
// // curl --location 'http://localhost:8080/v1/user' \
31+
// // --header 'Content-Type: application/json' \
32+
// // --data '[{"id": "123", "name": "Alice", "year": 20,
33+
// // "price": 100.5, "big": true, "car": false, "tags": ["fast", "blue"],
34+
// // "metadata": {"brand": "Tesla"}, "options": [{"key": "color", "value": "red"}],
35+
// // "extra": "some data", "dynamic": {"speed": "200km/h"}}]'
36+
// func main() {
37+
// // Create a new Echo instance
38+
// e := echo.New()
39+
40+
// // Define a POST route at /v1/user
41+
// e.POST("/v1/user", func(c echo.Context) error {
42+
// c.Set("Content-type", "application/json")
43+
44+
// var my []My // Slice to store multiple user objects
45+
46+
// // Bind the incoming JSON payload to the 'my' slice
47+
// if err := c.Bind(&my); err != nil {
48+
// // Return a Bad Request response if binding fails
49+
// return c.String(http.StatusBadRequest, err.Error())
50+
// }
51+
52+
// // Return the parsed JSON as a response
53+
// return c.JSON(http.StatusOK, my)
54+
// })
55+
56+
// // Start the Echo server on port 8080
57+
// e.Start(":8080")
58+
// }
+58-58
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,60 @@
11
package main
22

3-
import (
4-
"encoding/json"
5-
"net/http"
6-
7-
"github.com/labstack/echo/v4"
8-
)
9-
10-
// Struct representing a user model
11-
type My struct {
12-
ID string `json:"id"`
13-
Name string `json:"name"`
14-
Year int `json:"year"`
15-
Price float64 `json:"price"`
16-
Big bool `json:"big"`
17-
Car bool `json:"car"`
18-
Tags []string `json:"tags"`
19-
Metadata map[string]interface{} `json:"metadata"`
20-
Options []Option `json:"options"`
21-
Extra interface{} `json:"extra"`
22-
Dynamic map[string]interface{} `json:"dynamic"`
23-
}
24-
25-
// Struct representing an option with a key-value pair
26-
type Option struct {
27-
Key string `json:"key"`
28-
Value string `json:"value"`
29-
}
30-
31-
//curl --location 'http://localhost:8080/v1/user' \
32-
//--header 'Content-Type: application/json' \
33-
//--data '[{"id": "123", "name": "Alice", "year": 20, "price": 100.5, "big": true, "car": false, "tags": ["fast", "blue"], "metadata": {"brand": "Tesla"}, "options": [{"key": "color", "value": "red"}], "extra": "some data", "dynamic": {"speed": "200km/h"}}]'
34-
35-
func main() {
36-
e := echo.New()
37-
38-
// Define a POST route at /v1/user
39-
e.POST("/v1/user", func(c echo.Context) error {
40-
c.Set("Content-type", "application/json")
41-
42-
var my []My
43-
44-
err := json.NewDecoder(c.Request().Body).Decode(&my)
45-
if err != nil {
46-
return c.String(http.StatusBadRequest, "Error: "+err.Error())
47-
}
48-
49-
// Serialize users struct to JSON
50-
b, err := json.Marshal(my)
51-
if err != nil {
52-
return c.String(http.StatusBadRequest, "Error: "+err.Error())
53-
}
54-
55-
return c.Blob(http.StatusOK, "text/plain", b)
56-
//return c.JSON(http.StatusOK, my)
57-
})
58-
59-
e.Start(":8080")
60-
}
3+
// import (
4+
// "encoding/json"
5+
// "net/http"
6+
7+
// "github.com/labstack/echo/v4"
8+
// )
9+
10+
// // Struct representing a user model
11+
// type My struct {
12+
// ID string `json:"id"`
13+
// Name string `json:"name"`
14+
// Year int `json:"year"`
15+
// Price float64 `json:"price"`
16+
// Big bool `json:"big"`
17+
// Car bool `json:"car"`
18+
// Tags []string `json:"tags"`
19+
// Metadata map[string]interface{} `json:"metadata"`
20+
// Options []Option `json:"options"`
21+
// Extra interface{} `json:"extra"`
22+
// Dynamic map[string]interface{} `json:"dynamic"`
23+
// }
24+
25+
// // Struct representing an option with a key-value pair
26+
// type Option struct {
27+
// Key string `json:"key"`
28+
// Value string `json:"value"`
29+
// }
30+
31+
// //curl --location 'http://localhost:8080/v1/user' \
32+
// //--header 'Content-Type: application/json' \
33+
// //--data '[{"id": "123", "name": "Alice", "year": 20, "price": 100.5, "big": true, "car": false, "tags": ["fast", "blue"], "metadata": {"brand": "Tesla"}, "options": [{"key": "color", "value": "red"}], "extra": "some data", "dynamic": {"speed": "200km/h"}}]'
34+
35+
// func main() {
36+
// e := echo.New()
37+
38+
// // Define a POST route at /v1/user
39+
// e.POST("/v1/user", func(c echo.Context) error {
40+
// c.Set("Content-type", "application/json")
41+
42+
// var my []My
43+
44+
// err := json.NewDecoder(c.Request().Body).Decode(&my)
45+
// if err != nil {
46+
// return c.String(http.StatusBadRequest, "Error: "+err.Error())
47+
// }
48+
49+
// // Serialize users struct to JSON
50+
// b, err := json.Marshal(my)
51+
// if err != nil {
52+
// return c.String(http.StatusBadRequest, "Error: "+err.Error())
53+
// }
54+
55+
// return c.Blob(http.StatusOK, "text/plain", b)
56+
// //return c.JSON(http.StatusOK, my)
57+
// })
58+
59+
// e.Start(":8080")
60+
// }
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
package main
22

3-
import (
4-
"net/http"
3+
// import (
4+
// "net/http"
55

6-
"github.com/labstack/echo/v4"
7-
)
6+
// "github.com/labstack/echo/v4"
7+
// )
88

9-
// Struct representing a user model
10-
type My struct {
11-
Name string `json:"name"` // User's name
12-
Year int `json:"year"` // User's birth year
13-
}
9+
// // Struct representing a user model
10+
// type My struct {
11+
// Name string `json:"name"` // User's name
12+
// Year int `json:"year"` // User's birth year
13+
// }
1414

15-
func main() {
16-
e := echo.New()
15+
// func main() {
16+
// e := echo.New()
1717

18-
// Define a POST route at /v1/user
18+
// // Define a POST route at /v1/user
1919

20-
e.POST("/v1/user", func(c echo.Context) error {
21-
var my My
20+
// e.POST("/v1/user", func(c echo.Context) error {
21+
// var my My
2222

23-
if err := c.Bind(&my); err != nil {
23+
// if err := c.Bind(&my); err != nil {
2424

25-
return c.String(http.StatusBadRequest, err.Error())
26-
}
25+
// return c.String(http.StatusBadRequest, err.Error())
26+
// }
2727

28-
return c.JSON(http.StatusOK, my)
29-
})
28+
// return c.JSON(http.StatusOK, my)
29+
// })
3030

31-
e.Start(":8080")
32-
}
31+
// e.Start(":8080")
32+
// }
3333

34-
//curl --location 'http://localhost:8080/v1/user' \
35-
// --header 'Content-Type: application/json' \
36-
// --data '{"name": "Alice", "year": 20}'
34+
// //curl --location 'http://localhost:8080/v1/user' \
35+
// // --header 'Content-Type: application/json' \
36+
// // --data '{"name": "Alice", "year": 20}'
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
package main
22

3-
import (
4-
"encoding/json"
5-
"io"
6-
"net/http"
3+
// import (
4+
// "encoding/json"
5+
// "io"
6+
// "net/http"
77

8-
"github.com/labstack/echo/v4"
9-
)
8+
// "github.com/labstack/echo/v4"
9+
// )
1010

11-
// Struct representing a user model
12-
type My struct {
13-
Name string `json:"name"` // User's name
14-
Year int `json:"year"` // User's birth year
15-
}
11+
// // Struct representing a user model
12+
// type My struct {
13+
// Name string `json:"name"` // User's name
14+
// Year int `json:"year"` // User's birth year
15+
// }
1616

17-
// $ curl --location 'http://localhost:8080/v1/user' \
18-
// --header 'Content-Type: application/json' \
19-
// --data '{"name": "Alice", "year": 20}'
20-
func main() {
21-
e := echo.New()
17+
// // $ curl --location 'http://localhost:8080/v1/user' \
18+
// // --header 'Content-Type: application/json' \
19+
// // --data '{"name": "Alice", "year": 20}'
20+
// func main() {
21+
// e := echo.New()
2222

23-
// Define a POST route at /v1/user
23+
// // Define a POST route at /v1/user
2424

25-
e.POST("/v1/user", func(c echo.Context) error {
26-
var my My
25+
// e.POST("/v1/user", func(c echo.Context) error {
26+
// var my My
2727

28-
body, err := io.ReadAll(c.Request().Body)
29-
if err != nil {
30-
return c.String(http.StatusInternalServerError, "Erro ao ler o body: "+err.Error())
31-
}
28+
// body, err := io.ReadAll(c.Request().Body)
29+
// if err != nil {
30+
// return c.String(http.StatusInternalServerError, "Erro ao ler o body: "+err.Error())
31+
// }
3232

33-
if err := json.Unmarshal(body, &my); err != nil {
34-
return c.String(http.StatusBadRequest, "Erro ao decodificar JSON: "+err.Error())
35-
}
33+
// if err := json.Unmarshal(body, &my); err != nil {
34+
// return c.String(http.StatusBadRequest, "Erro ao decodificar JSON: "+err.Error())
35+
// }
3636

37-
return c.JSON(http.StatusOK, my)
38-
})
37+
// return c.JSON(http.StatusOK, my)
38+
// })
3939

40-
e.Start(":8080")
41-
}
40+
// e.Start(":8080")
41+
// }

0 commit comments

Comments
 (0)