Skip to content
zelenko edited this page Sep 14, 2020 · 16 revisions

test this code

resp, err := http.Get("http://example.com/")
...
resp, err := http.Post("http://example.com/upload", "image/jpeg", &buf)
...
resp, err := http.PostForm("http://example.com/form",
	url.Values{"key": {"Value"}, "id": {"123"}})

update all packages: go get -u all

format code: gofmt -s -w .

Working on core infrastructure and user facing applications.

Twitter Readme Score release mit

https://gitmemory.com/zelenko/go

Tools

VS Code Extensions

Documentation

Converting stuff

Struct can have blank fields (try in playground)

package main

import "fmt"

func main() {
	for _, book := range []struct {
		title     string
		published uint16
	}{
		{title: "Go Recipes"},  // title only given
		{"Go in Action", 2016}, // title and year given
	} {
		fmt.Printf(book.title+":\t%+v\n", book)
	}
}
// Go Recipes:	{title:Go Recipes published:0}
// Go in Action:	{title:Go in Action published:2016}

Create Presentation (PowerPoint alternative)

go get golang.org/x/tools/cmd/present

go build golang.org/x/tools/cmd/present

Validate Input

func validInput(input string) bool {
	switch input {
	case "Option1", "OPtion2", "valid1", "valid2", "valid3":
		return true
	}
	return false
}

AlphaNumeric

func alphaNumeric(input string) string {
	reg, _ := regexp.Compile("[^a-zA-Z0-9]+")
	return reg.ReplaceAllString(input, "")
}

Convert string to uint64

newNumber, err := strconv.ParseUint("100", 10, 64)

Go GUI apps on Windows

Clone this wiki locally