Skip to content
Zelenko edited this page Apr 21, 2019 · 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

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

Valid Input

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

AlphaNumeeric

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