This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Methods | |
(() => { | |
let a = 5; | |
let b = { a: 4 }; | |
((c, d) => { | |
c = 4; | |
d.a = 5; | |
})(a, b); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
// Print "Hello, World!" to the console | |
fmt.Println("Hello, World!") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module hello | |
go 1.15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### Stage 1 ##### | |
### Use golang:1.15 as base image for building the application | |
FROM golang:1.15 as builder | |
### Create new directly and set it as working directory | |
RUN mkdir -p /app | |
WORKDIR /app | |
### Copy Go application dependency files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "github.com/gofiber/fiber/v2" // <-- Import Fiber | |
func main() { | |
// Create new Fiber application | |
app := fiber.New() | |
// Create a route on the default path, only returning some string | |
app.Get("/", func(c *fiber.Ctx) error { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module medium_go_fiber_swagger | |
go 1.15 | |
require ( | |
github.com/andybalholm/brotli v1.0.1 // indirect | |
github.com/gofiber/fiber/v2 v2.5.0 // indirect | |
github.com/klauspost/compress v1.11.7 // indirect | |
github.com/valyala/fasthttp v1.20.0 // indirect | |
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
// Import Fiber Swagger | |
"github.com/arsmn/fiber-swagger/v2" | |
// Import Go Fiber | |
"github.com/gofiber/fiber/v2" | |
// Side Effect import for auto-generated swagger documentation | |
_ "medium_go_fiber_swagger/docs" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func readCSVFile(filePath string) (persons []Person) { | |
isFirstRow := true | |
headerMap := make(map[string]int) | |
// Load a csv file. | |
f, _ := os.Open(filePath) | |
// Create a new reader. | |
r := csv.NewReader(f) | |
for { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func checkError(message string, err error) { | |
// Error Logging | |
if err != nil { | |
log.Fatal(message, err) | |
} | |
} | |
type Person struct { | |
Firstname string | |
Lastname string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func writeCSVFile(persons []Person, outputPath string) { | |
// Define header row | |
headerRow := []string{ | |
"Firstname", "Lastname", "Country", | |
} | |
// Data array to write to CSV | |
data := [][]string{ | |
headerRow, | |
} |