25. ? Go????
Go? ? ???? ????
????? ??
? ??? Full-featured Debugger? ??
the ability to use the debugger to understand a Go program's
full environment will likely never work, and improving gdb
support is not a priority for the team.
- Rob Pike, on March 2014
???? Debugger (gdb, lldb, delve, godebug, ) ?
? ??? ???? Go ?? ??? ??? print?? ????
? Function call ? ???? ???
? Goroutine? ?? ?? ? ??? ???? ???
25
55. Test function
testing/quick
??? ??? ??????
Go? ? ???? ????
func TestOddMultipleOfThree(t *testing.T) {
f := func(x int) bool {
y := OddMultipleOfThree(x)
return y%2 == 1 && y%3 == 0
}
if err := quick.Check(f, nil); err != nil {
t.Error(err)
}
}
Target function
Inject random
valid parameter
Check if target function
is working well
55
57. Cine
??? ??? ??????
Go? ? ???? ????
github.com/devsisters/cine
? Actor model for Go (like erlang)
? All actor is identified by unique PID
? Remote actor is treated same as local one
? Supports synchronous / asynchronous function call
Cine
Host 1 Host 2 Host 3
Actor Actor Actor Actor Actor
57
58. Cine
??? ??? ??????
Go? ? ???? ????
github.com/devsisters/cine
type Phonebook struct {
cine.Actor
book map[string]int
}
cine.Init("127.0.0.1:8000")
phonebook := Phonebook{cine.Actor{}, make(map[string]int)}
pid := cine.StartActor(&phonebook)
// For asynchronous call (ignore all errors)
cine.Cast(pid, nil, (*Phonebook).Add, "Jane", 1234)
// For synchronous call
ret, _ := cine.Call(pid, (*Phonebook).Lookup, "Jane")
number := ret[0].(int)
58