This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Playing with functions | |
// This is really useful | |
package main | |
import "fmt" | |
func greet() { | |
fmt.Println("Hello!") | |
} | |
func farewell() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
myString := "OLapOKA3EOR" | |
t := 0 | |
for _, value := range myString { | |
switch value { | |
case 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
myString := "OLapOKA3EOR" | |
t := 0 | |
for _, value := range myString { | |
switch { | |
case value >= '0' && value <= '9': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
for i, j := 0, 1; j < 100; i, j = i+j,i { | |
fmt.Println(i) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From effective Go | |
// Compare returns an integer comparing the two byte slices, | |
// lexicographically. | |
// The result will be 0 if a == b, -1 if a < b, and +1 if a > b | |
package main | |
import "fmt" | |
func Compare(a, b []byte) int { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
str := "abc" | |
mySlice := []byte(str) | |
fmt.Printf("%v -> '%s'",mySlice,mySlice ) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"startTime":1373528184507.288, | |
"data":{ | |
}, | |
"children":[ | |
{ | |
"startTime":1373528184507.834, | |
"data":{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include $(GOROOT)/src/Make.inc | |
GOFMT=gofmt -spaces=true -tabindent=false -tabwidth=4 | |
all: | |
$(GC) jsontest.go | |
$(LD) -o jsontest.out jsontest.$O | |
format: | |
$(GOFMT) -w jsontest.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func GetId(s string) string { | |
i := strings.Index(s[0:], "ID=") | |
if i == -1 { | |
return "" | |
} | |
return s[i+3 : i+18] | |
} | |
var idRegex = regexp.MustCompile(`ID=(.*?)<`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
import "strings" | |
func main() { | |
someString := "one two three four " | |
words := strings.Fields(someString) | |
OlderNewer