Upgrade to Pro — share decks privately, control downloads, hide ads and more …

menjadi backend engineer

menjadi backend engineer

Avatar for Edwin Andrianto

Edwin Andrianto

October 15, 2022

Other Decks in Programming

Transcript

  1. Bootcamp Web Development DISCLAIMER 🙌 Saya tidak mewakili institusi mana

    pun, semua materi merupakan pendapat pribadi. Materi dimaksudkan untuk belajar bersama dan bersifat subjektif dan mungkin tidak sesuai dengan kondisi kalian. Segala resiko kesalahan penerjemahan maksud dari materi bukan menjadi tanggung jawab saya.
  2. Bootcamp Web Development users see 💆 20% of total effort

    users dont see 💁 80% of total effort source: dev.to
  3. Bootcamp Web Development backend APIs authentication & authorization DB cache

    system messaging web security CI/CD Containerization etc…
  4. Bootcamp Web Development first collaboration 💨 please fork, commit and

    make pull request from this repo: https://github.com/edwinlab/b
  5. Bootcamp Web Development feature - open source - typesafe -

    built-in concurrency - compiled - fast build - adopt by industries
  6. Bootcamp Web Development run first code package main func main()

    { print("halo") } https://go.dev/play/ run: $ go run main.go build & execute: $ go build && ./main
  7. Bootcamp Web Development struct package main import "fmt" type car

    struct { brand string wheels int } func main() { var ionic car ionic.brand = "Hyundai" ionic.wheels = 4 fmt.Println("brand :", ionic.brand) fmt.Println("wheel :", ionic.wheels) }
  8. Bootcamp Web Development array type Car struct { ID string

    `json:"id"` Brand string `json:"brand"` Type string `json:"type"` } var cars = []Car{ {ID: "1", Brand: "Honda", Type: "City"}, {ID: "2", Brand: "Hyundai", Type: "Ionic 5"}, }
  9. Bootcamp Web Development function package main import "fmt" func printMessage(message

    string) { fmt.Println(message) } func main() { printMessage("hello") } package main import "fmt" func twoReturn(i int) (int, int) { return i + 1, i + 2 } func main() { fmt.Println(twoReturn(10)) }
  10. Bootcamp Web Development error = value property .Error() return as

    string func errAsString(err error) string { return err.Error() }
  11. Bootcamp Web Development goroutine package main import ( "fmt" "runtime"

    "time" ) func run(message string) { for i := 0; i < 5; i++ { time.Sleep(3 * time.Second) fmt.Println(message) } } func main() { runtime.GOMAXPROCS(2) go run("goroutine") run("sequence") } package main import ( "fmt" "runtime" "time" ) func channel(ch chan string, message string) { time.Sleep(3 * time.Second) var data = fmt.Sprintf(message) ch <- data } func main() { runtime.GOMAXPROCS(2) var messages = make(chan string) go channel(messages, "channel 1") go channel(messages, "channel 2") go channel(messages, "channel 3") var message1 = <-messages fmt.Println(message1) var message2 = <-messages fmt.Println(message2) var message3 = <-messages fmt.Println(message3) } channel
  12. Bootcamp Web Development RESTFul API GET http://api.aplikasimu.com/v1/messages/1 POST http://api.aplikasimu.com/v1/messages PUT

    http://api.aplikasimu.com/v1/messages/1 DELETE http://api.aplikasimu.com/v1/messages/1
  13. Bootcamp Web Development example $ curl --header "Content-Type: application/json"\ --request

    POST\ --data '{"username":"xyz","password":"xyz"}'\ http://localhost:3000/api/v1/users?page=1 < HTTP/1.1 200 OK < Content-Type: application/json; < {"message":"Hello World!"}
  14. Bootcamp Web Development first api package main import ( "net/http"

    "github.com/gin-gonic/gin" ) func main() { r := gin.New() r.GET("/", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "message": "Hello World!", }) }) r.Run() } $ go get $ go mod tidy $ go run main.go
  15. Bootcamp Web Development what’s next? - automation testing - secure

    api (jwt) - telemetry (traces, metric, log) - CI/CD - api documentation - many more…