What do you want to save?
Add Code snippet
New code examples
-
Go 2021-11-13 13:07:19
webscraper using Go
# Web Scraper in Golang # source: golangcode.com/basic-web-scraper package main import ( "fmt" "log" "net/http" "github.com/PuerkitoBio/goquery" ) func main() { blogTitles, err := GetLatestBlogTitles(&quo... Add solution -
Go 2021-11-09 03:02:14
golang passing parameter to the program
package main import ( "fmt" "os" ) func main() { argsWithProg := os.Args argsWithoutProg := os.Args[1:] You can get individual args with normal indexing. arg := os.Args[3] fmt.Println(argsWithProg) fmt.Pri... Add solution -
Go 2021-11-07 00:14:13
receive from multiple channels golang
package main import ( "fmt" "sync" ) func main() { c1 := make(chan int) c2 := make(chan int) go sender(c1) go sender(c2) receiver(c1, c2) } func sender(c chan<- int) { defer close(c) for i := 0; i < 10; i++ { c &... Add solution -
Go 2021-11-06 23:14:08
go change json key struct
type Person struct { Name string `json:"person_name"` Surname string `json:"person_surname"` } func main(){ Bytes, err := json.Marshal(Person{"Joe", "Soap"}) if err != nil { log.Fatal(err.Error()) } ... Add solution -
Go 2021-11-06 14:34:22
gorm mysql unique constraint show errors example
type GormErr struct { Number int `json:"Number"` Message string `json:"Message"` } err, _ = DoFuncOnDB(); // funtion to do some ops on DB byteErr, _ := json.Marshal(err) var newError types.GormErr json.Unmarshal((byteErr), &a... Add solution -
Go 2021-11-03 10:52:13
goland print the time it took for code to run
package main import ( "time" // Import this to be able to track time "fmt" // Import this to print in console ) //This app will check how long it takes for the computer to print 2000 numbers func main () { start := time.Now() ... Add solution -
Go 2021-11-01 19:57:17
golang find in string
package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.Contains("Assume", "Ass")) fmt.Println(strings.ContainsAny("team", "i")) fmt.Println(strings.ContainsAny("He... Add solution