This file contains hidden or 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" | |
"time" | |
) | |
func main() { | |
var ch chan int |
This file contains hidden or 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
(dlv) vars | |
panic: runtime error: makeslice: len out of range | |
goroutine 75 [running]: | |
panic(0x4620220, 0xc820ea3f30) | |
/usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6 | |
github.com/derekparker/delve/proc.(*Thread).readMemory(0xc820d76190, 0xc820090000, 0xfffffffffffffff0, 0x0, 0x0, 0x0, 0x0, 0x0) | |
/private/tmp/delve20160603-64173-7ebqc8/delve-0.11.0-alpha/src/github.com/derekparker/delve/proc/threads_darwin.go:112 +0x9c | |
github.com/derekparker/delve/proc.cacheMemory(0x61a0ad8, 0xc820ef92f0, 0xc820090000, 0xfffffffffffffff0, 0x0, 0x0) | |
/private/tmp/delve20160603-64173-7ebqc8/delve-0.11.0-alpha/src/github.com/derekparker/delve/proc/mem.go:42 +0xf2 |
This file contains hidden or 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
index - 3, value - 4 | |
index - 3, value - 4 | |
index - 3, value - 4 | |
index - 3, value - 4 |
This file contains hidden or 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 functions() []func() { | |
// pitfall of using loop variables | |
arr := []int{1, 2, 3, 4} | |
result := make([]func(), 0) | |
// functions are not evaluated, functions definitions are returned |
This file contains hidden or 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
counter - 100 | |
counter1 - 100 | |
counter - 101 | |
counter1- 100 | |
counter - 101 | |
counter1- 102 |
This file contains hidden or 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 counter(start int) (func() int, func()) { | |
// if the value gets mutated, the same is reflected in closure | |
ctr := func() int { | |
return start | |
} |
This file contains hidden or 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 outer(name string) func() { | |
// variable | |
text := "Modified " + name | |
// closure. function has access to text even after exiting this block | |
foo := func() { |
This file contains hidden or 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 outer(name string) { | |
// variable in outer function | |
text := "Modified " + name | |
// foo is a inner function and has access to text variable, is a closure | |
// closures have access to variables even after exiting this block |
This file contains hidden or 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 printMessage(message string) { | |
fmt.Println(message) | |
} | |
func getPrintMessage() func(string) { | |
// returns an anonymous function |
This file contains hidden or 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
box: debian | |
build: | |
steps: | |
- script: | |
name: install git | |
code: | | |
apt-get update | |
apt-get install git -y | |
- script: | |
name: fetch theme sub module |