package main /* Author: Valentijn van der Jagt In this project i play around with go. This is my first time writing go, and im using a lot of help from sources. all useful sources are listed in the comments below. */ // https://stackoverflow.com/questions/61080317/go-lang-very-simple-http-post-requests-and-response-endpoint, HTTP Server example // https://stackoverflow.com/questions/16466320/is-there-a-way-to-do-repetitive-tasks-at-intervals, How timer intervals work in GoLang // https://pkg.go.dev/modernc.org/sqlite#section-documentation, how to interface with specifically sqlite in GoLang // https://github.com/mattn/go-sqlite3/blob/v1.14.34/_example/simple/simple.go, How to inferface with a database in GoLang. import ( "database/sql" "log" "errors" _ "modernc.org/sqlite" ) func findParcelProvider(code string, postal_code string)(string, error){ providers := [4]string{"express", "parcel-nl", "ecommerce", "ecommerce-europe"} for _, v := range providers { // do http api reqiest success := false if (success){ return v, nil } } return "", errors.New("parcel not found!") } func main() { db, err := sql.Open("sqlite", "./dhl.db") if err != nil { log.Fatal(err) } defer db.Close() code := "blablbla" postal := "1234ab" provider, err := findParcelProvider(code, postal) if (err != nil){ log.Fatal(err) } log.Printf("Code: %s, Postal Code: %s, Tracking Service: %s", code, postal, provider) }