Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Go <=> Ruby a selection of odd lightning talks            @feyeleanorhttp://slides.games-with-brains.net/
The Wild-Eyed  Screamer
@feyeleanorrealtime
@feyeleanorrealtimenet working
@feyeleanorrealtimenet workingunix
@feyeleanorrealtimenet workingunixlanguages
@feyeleanorrealtimenet workingunixlanguagesvirtual machines
Hacker 101this presentation contains code
Hacker 101this presentation contains codethat code is probably broken
Hacker 101this presentation contains codethat code is probably brokenif this bothers you - fix it
Hacker 101this presentation contains codethat code is probably brokenif this bothers you - fix itit’s called a learning exp...
Hacker 101this presentation contains codethat code is probably brokenif this bothers you - fix itit’s called a learning exp...
Google Goit’s not just for Google
meet Gordon
he’s a gopher
of very few words
who lives at google
package mainimport "fmt"const HELLO string = "hello"var WORLD string = "world"func main() {	    fmt.Println(HELLO, WORLD)}
package mainimport "fmt"const HELLO string = "hello"var WORLD string = "world"func main() {	    fmt.Println(HELLO, WORLD)}
package mainimport "fmt"const HELLO string = "hello"var WORLD string = "world"func main() {	    fmt.Println(HELLO, WORLD)}
package mainimport "fmt"const HELLO string = "hello"var WORLD string = "world"func main() {	    fmt.Println(HELLO, WORLD)}
packageorganisation                    import                           var, const, typedeclaration                 func, ...
boolean, numeric, array  value                    structure, interfacereference    pointer, slice, string, map, channelinv...
Go                       Rubycompilation        static AOT            runtime mutable memory                     garbage c...
Ruby typing is tricksy    lies we tell ourself about type
superclass   modulesclass        modules                   message        instance
superclass   modules         class        modulestype asserted                 instance
instance               inherited  class                  class           expressed             type           modules
instance               inherited  class                  class           expressed             type           modules
instance               inherited  class                  class           expressed             type           modules
instance               inherited  class                  class           expressed             type           modules
class Counter	    attr_writer	   :count	    def initialize	    	    @count = 0	    end	   def Tick	   	    @count += 1	   ...
class Counter	    attr_writer	   :count	    def initialize	    	    @count = 0	    end	   def Tick	   	    @count += 1	   ...
class Counter	    attr_writer	   :count	    def initialize	    	    @count = 0	    end	   def Tick	   	    @count += 1	   ...
class Counter	    attr_writer	   :count	    def initialize	    	    @count = 0	    end	   def Tick	   	    @count += 1	   ...
class Counter	    attr_writer	   :count	    def initialize	    	    @count = 0	    end	   def Tick	   	    @count += 1	   ...
class Counter	    attr_writer	   :count	    def initialize	    	    @count = 0	    end	   def Tick	   	    @count += 1	   ...
down a rabbit holeinstances are their own classes
down a rabbit holeinstances are their own classesand all classes are mutable at runtime
down a rabbit holeinstances are their own classesall classes are mutable at runtimeso inheritance pathways can be altered
down a rabbit holeinstances are their own classesand all classes are mutable at runtimeso inheritance pathways can be alte...
down a rabbit holeinstances are their own classesand all classes are mutable at runtimeso inheritance pathways can be alte...
down a rabbit holeinstances are their own classesand all classes are mutable at runtimeso inheritance pathways can be alte...
type in Go is                safetmclearly defined areas of doubt and uncertainty
memory               method layout               set           static            type          embedded           types
memory               method layout               set           static            type          embedded           types
memory               method layout               set           static            type          embedded           types
memory               method layout               set           static            type          embedded           types
package Integertype Int intfunc (i *Int) Add(x int) {	    *i += Int(x)}
package Integertype Int intfunc (i *Int) Add(x int) {	    *i += Int(x)}
package Integertype Int intfunc (i *Int) Add(x int) {	    *i += Int(x)}
package Integertype Int intfunc (i *Int) Add(x int) {	    *i += Int(x)}
type Buffer []Intfunc (b Buffer) Swap(i, j int) {	    b[i], b[j] = b[j], b[i]}func (b Buffer) Clone() Buffer {	    s := ma...
type Buffer []Intfunc (b Buffer) Swap(i, j int) {	    b[i], b[j] = b[j], b[i]}func (b Buffer) Clone() Buffer {	    s := ma...
type Buffer []Intfunc (b Buffer) Swap(i, j int) {	    b[i], b[j] = b[j], b[i]}func (b Buffer) Clone() Buffer {	    s := ma...
package mainimport "fmt"import "Integer"func main() {	    i := Integer.Buffer{0, 1, 2, 3, 4, 5}	    b := i.Clone()	    b.S...
package mainimport "fmt"import "Integer"func main() {	    i := Integer.Buffer{0, 1, 2, 3, 4, 5}	    b := i.Clone()	    b.S...
package mainimport "fmt"import "Integer"func main() {	    i := Integer.Buffer{0, 1, 2, 3, 4, 5}	    b := i.Clone()	    b.S...
package mainimport "fmt"import "Integer"func main() {	    i := Integer.Buffer{0, 1, 2, 3, 4, 5}	    b := i.Clone()	    b.S...
package mainimport "fmt"import "Integer"func main() {	    i := Integer.Buffer{0, 1, 2, 3, 4, 5}	    b := i.Clone()	    b.S...
package Vectorimport . "Integer"type Vector struct {	    Buffer}func (v *Vector) Clone() *Vector {	    return &Vector{v.Bu...
package Vectorimport . "Integer"type Vector struct {	    Buffer}func (v *Vector) Clone() *Vector {	    return &Vector{v.Bu...
package Vectorimport . "Integer"type Vector struct {	    Buffer}func (v *Vector) Clone() *Vector {	    return &Vector{v.Bu...
package Vectorimport . "Integer"type Vector struct {	    Buffer}func (v *Vector) Clone() *Vector {	    return &Vector{v.Bu...
package Vectorimport . "Integer"type Vector struct {	    Buffer}func (v *Vector) Clone() *Vector {	    return &Vector{v.Bu...
type Adder interface {	    Add(j int)	    Subtract(j int)	    Result() interface{}	    Reset()}
type Adder interface {	    Add(j int)	    Subtract(j int)	    Result() interface{}	    Reset()}
type Adder interface {	    Add(j int)	    Subtract(j int)	    Result() interface{}	    Reset()}
type IAdder intfunc (i IAdder) Add(j int) {	    i[0] += i[j]}func (i IAdder) Subtract(j int) {	    i[0] -= i[j]}func (i IA...
type IAdder intfunc (i IAdder) Add(j int) {	    i[0] += i[j]}func (i IAdder) Subtract(j int) {	    i[0] -= i[j]}func (i IA...
type IAdder intfunc (i IAdder) Add(j int) {	    i[0] += i[j]}func (i IAdder) Subtract(j int) {	    i[0] -= i[j]}func (i IA...
type FAdder []float32func (f FAdder) Add(j int) {	    f[0] += f[j]}func (f FAdder) Subtract(j int) {	    f[0] -= f[j]}func ...
type FAdder []float32func (f FAdder) Add(j int) {	    f[0] += f[j]}func (f FAdder) Subtract(j int) {	    f[0] -= f[j]}func ...
type FAdder []float32func (f FAdder) Add(j int) {	    f[0] += f[j]}func (f FAdder) Subtract(j int) {	    f[0] -= f[j]}func ...
func TestAdder(t *testing.T) {	    var a	  Adder	   a = IAdder{0, 1, 2}	   a.Add(1)	   if i.Result().(int) != 1 {	   	    ...
func TestAdder(t *testing.T) {	    var a	  Adder	   a = IAdder{0, 1, 2}	   a.Add(1)	   if i.Result().(int) != 1 {	   	    ...
func TestAdder(t *testing.T) {	    var a	  Adder	   a = IAdder{0, 1, 2}	   a.Add(1)	   if i.Result().(int) != 1 {	   	    ...
func TestAdder(t *testing.T) {	    var a	  Adder	   a = IAdder{0, 1, 2}	   a.Add(1)	   if i.Result().(int) != 1 {	   	    ...
func TestAdder(t *testing.T) {	    var a	  Adder	   a = IAdder{0, 1, 2}	   a.Add(1)	   if i.Result().(int) != 1 {	   	    ...
func TestAdder(t *testing.T) {	    var a	  Adder	   a = IAdder{0, 1, 2}	   a.Add(1)	   if i.Result().(int) != 1 {	   	    ...
func TestAdder(t *testing.T) {	    var a	  Adder	   a = IAdder{0, 1, 2}	   a.Add(1)	   if i.Result().(int) != 1 {	   	    ...
down a rabbit holean object has known static type
down a rabbit holean object has known static typethis fixed type is determined at linking
down a rabbit holean object has known static typethis fixed type is determined at linkingno new types can be created at run...
down a rabbit holean object has known static typethis fixed type is determined at linkingno new types can be created at run...
down a rabbit holean object has known static typethis fixed type is determined at linkingno new types can be created at run...
unit tests as REPL   testing that doesn’t suck
func (b Buffer) Eq(o Buffer) (r bool) {	    if len(b) == len(o) {	    	     for i := len(b) - 1; i > 0; i-- {	    	     	 ...
func (b Buffer) Eq(o Buffer) (r bool) {	    if len(b) == len(o) {	    	     for i := len(b) - 1; i > 0; i-- {	    	     	 ...
func (b Buffer) Eq(o Buffer) (r bool) {	    if len(b) == len(o) {	    	     for i := len(b) - 1; i > 0; i-- {	    	     	 ...
func (b Buffer) Eq(o Buffer) (r bool) {	    if len(b) == len(o) {	    	     for i := len(b) - 1; i > 0; i-- {	    	     	 ...
func (b Buffer) Eq(o Buffer) (r bool) {	    if len(b) == len(o) {	    	     for i := len(b) - 1; i > 0; i-- {	    	     	 ...
func (b Buffer) Eq(o Buffer) (r bool) {	    if len(b) == len(o) {	    	     for i := len(b) - 1; i > 0; i-- {	    	     	 ...
func (b Buffer) Eq(o Buffer) (r bool) {	    if len(b) == len(o) {	    	     for i := len(b) - 1; i > 0; i-- {	    	     	 ...
package Vectorimport "testing"func TestVectorSwap(t *testing.T) {	    i := Vector{Buffer{0, 1, 2, 3, 4, 5}}	    v := i.Clo...
package Vectorimport "testing"func TestVectorSwap(t *testing.T) {	    i := Vector{Buffer{0, 1, 2, 3, 4, 5}}	    v := i.Clo...
package Vectorimport "testing"func TestVectorSwap(t *testing.T) {	    i := Vector{Buffer{0, 1, 2, 3, 4, 5}}	    v := i.Clo...
package Vectorimport "testing"func TestVectorSwap(t *testing.T) {	    i := Vector{Buffer{0, 1, 2, 3, 4, 5}}	    v := i.Clo...
package Vectorimport "testing"func TestVectorSwap(t *testing.T) {	    i := Vector{Buffer{0, 1, 2, 3, 4, 5}}	    v := i.Clo...
package Vectorimport "testing"func TestVectorSwap(t *testing.T) {	    i := Vector{Buffer{0, 1, 2, 3, 4, 5}}	    v := i.Clo...
package Vectorimport "testing"func TestVectorSwap(t *testing.T) {	    i := Vector{Buffer{0, 1, 2, 3, 4, 5}}	    v := i.Clo...
package Vectorimport "testing"func TestVectorSwap(t *testing.T) {	    i := Vector{Buffer{0, 1, 2, 3, 4, 5}}	    v := i.Clo...
include $(GOROOT)/src/Make.incTARG=integerGOFILES=	   integer.go	   vector.goinclude $(GOROOT)/src/Make.pkg
package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) {	    v := Vector{Buffer{0, 1, 2, 3,...
package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) {	    v := Vector{Buffer{0, 1, 2, 3,...
package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) {	    v := Vector{Buffer{0, 1, 2, 3,...
package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) {	    v := Vector{Buffer{0, 1, 2, 3,...
package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) {	    v := Vector{Buffer{0, 1, 2, 3,...
package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) {	    v := Vector{Buffer{0, 1, 2, 3,...
$ gotest -bench="Benchmark"rm -f _test/scripts.a6g -o _gotest_.6 integer.go vector.go nominal_typing_test.goembedded_typin...
$ gotest -bench="Benchmark"rm -f _test/scripts.a6g -o _gotest_.6 integer.go vector.go nominal_typing_test.goembedded_typin...
$ gotest -bench="Benchmark"rm -f _test/scripts.a6g -o _gotest_.6 integer.go vector.go nominal_typing_test.goembedded_typin...
$ gotest -bench="Benchmark"rm -f _test/scripts.a6g -o _gotest_.6 integer.go vector.go nominal_typing_test.goembedded_typin...
$ gotest -bench="Benchmark"rm -f _test/scripts.a6g -o _gotest_.6 integer.go vector.go nominal_typing_test.goembedded_typin...
exceptional funbecause Go doesn’t have exceptions - honest!
func Throw() {	    panic(nil)}func Catch(f func()) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	 ...
func Throw() {	    panic(nil)}func Catch(f func()) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	 ...
func Throw() {	    panic(nil)}func Catch(f func()) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	 ...
func Throw() {	    panic(nil)}func Catch(f func()) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	 ...
func Throw() {	    panic(nil)}func Catch(f func()) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	 ...
func Throw() {	    panic(nil)}func Catch(f func()) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	 ...
func Throw() {	    panic(nil)}func Catch(f func()) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	 ...
func Throw() {	    panic(nil)}func Catch(f func()) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	 ...
func Throw() {	    panic(nil)}func Catch(f func()) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	 ...
func Throw() {	    panic(nil)}func Catch(f func()) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	 ...
func throwsPanic(f func()) (b bool) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	     b = true	  ...
func throwsPanic(f func()) (b bool) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	     b = true	  ...
func throwsPanic(f func()) (b bool) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	     b = true	  ...
func throwsPanic(f func()) (b bool) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	     b = true	  ...
func throwsPanic(f func()) (b bool) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	     b = true	  ...
func throwsPanic(f func()) (b bool) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	     b = true	  ...
func throwsPanic(f func()) (b bool) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	     b = true	  ...
func throwsPanic(f func()) (b bool) {	    defer func() {	    	    if x := recover(); x != nil {	    	    	     b = true	  ...
import "fmt"import "path"import "runtime"func StackTrace() {	    var stack_trace	   []uintptr	    var my_path	 	     strin...
import "fmt"import "path"import "runtime"func StackTrace() {	    var stack_trace	   []uintptr	    var my_path	 	     strin...
import "fmt"import "path"import "runtime"func StackTrace() {	    var stack_trace	   []uintptr	    var my_path	 	     strin...
import "fmt"import "path"import "runtime"func StackTrace() {	    var stack_trace	   []uintptr	    var my_path	 	     strin...
import "fmt"import "path"import "runtime"func StackTrace() {	    var stack_trace	   []uintptr	    var my_path	 	     strin...
import "fmt"import "path"import "runtime"func StackTrace() {	    var stack_trace	   []uintptr	    var my_path	 	     strin...
import "fmt"import "path"import "runtime"func StackTrace() {	    var stack_trace	   []uintptr	    var my_path	 	     strin...
import "fmt"import "path"import "runtime"func StackTrace() {	    var stack_trace	   []uintptr	    var my_path	 	     strin...
import "fmt"import "path"import "runtime"func StackTrace() {	    var stack_trace	   []uintptr	    var my_path	 	     strin...
import "fmt"import "path"import "runtime"func StackTrace() {	    var stack_trace	   []uintptr	    var my_path	 	     strin...
import "fmt"import "path"import "runtime"func StackTrace() {	    var stack_trace	   []uintptr	    var my_path	 	     strin...
reflections on Godynamism through run-time type manipulation
package generaliseimport "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := reflect.Value...
package generaliseimport "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := reflect.Value...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) {	    switch v := ValueOf(i)...
func TestAllocate(t *testing.T) {	    var s2 []int	   s1 := []int{0, 1, 2}	   m := map[int] int{1: 1, 2: 2, 3: 3}	   switc...
func TestAllocate(t *testing.T) {	    var s2 []int	   s1 := []int{0, 1, 2}	   m := map[int] int{1: 1, 2: 2, 3: 3}	   switc...
func TestAllocate(t *testing.T) {	    var s2 []int	   s1 := []int{0, 1, 2}	   m := map[int] int{1: 1, 2: 2, 3: 3}	   switc...
func TestAllocate(t *testing.T) {	    var s2 []int	   s1 := []int{0, 1, 2}	   m := map[int] int{1: 1, 2: 2, 3: 3}	   switc...
func TestAllocate(t *testing.T) {	    var s2 []int	   s1 := []int{0, 1, 2}	   m := map[int] int{1: 1, 2: 2, 3: 3}	   switc...
func TestAllocate(t *testing.T) {	    var s2 []int	   s1 := []int{0, 1, 2}	   m := map[int] int{1: 1, 2: 2, 3: 3}	   switc...
func TestAllocate(t *testing.T) {	    var s2 []int	   s1 := []int{0, 1, 2}	   m := map[int] int{1: 1, 2: 2, 3: 3}	   switc...
func TestAllocate(t *testing.T) {	    var s2 []int	   s1 := []int{0, 1, 2}	   m := map[int] int{1: 1, 2: 2, 3: 3}	   switc...
func TestAllocate(t *testing.T) {	    var s2 []int	   s1 := []int{0, 1, 2}	   m := map[int] int{1: 1, 2: 2, 3: 3}	   switc...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
func Duplicate(i interface{}) (clone interface{}) {	    if clone = Allocate(i); clone != nil {	    	     switch clone := V...
metallic k.o.sometimes a bit-buffer is just a bit-buffer
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface {	    Byte...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) {	    switch value := Indirect(ValueOf(i)); value.K...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
func ByteSlice(i interface{}) []byte {	    switch i := i.(type) {	    case []byte:	 	      	  	    return i	    case Memor...
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Go &lt;-> Ruby
Upcoming SlideShare
Loading in …5
×

Go &lt;-> Ruby

11,624 views

Published on

A rambling mashup of hardcore Go hackery and occasional Ruby madness.

Published in: Technology, Education
  • Be the first to comment

Go &lt;-> Ruby

  1. Go <=> Ruby a selection of odd lightning talks @feyeleanorhttp://slides.games-with-brains.net/
  2. The Wild-Eyed Screamer
  3. @feyeleanorrealtime
  4. @feyeleanorrealtimenet working
  5. @feyeleanorrealtimenet workingunix
  6. @feyeleanorrealtimenet workingunixlanguages
  7. @feyeleanorrealtimenet workingunixlanguagesvirtual machines
  8. Hacker 101this presentation contains code
  9. Hacker 101this presentation contains codethat code is probably broken
  10. Hacker 101this presentation contains codethat code is probably brokenif this bothers you - fix it
  11. Hacker 101this presentation contains codethat code is probably brokenif this bothers you - fix itit’s called a learning experience
  12. Hacker 101this presentation contains codethat code is probably brokenif this bothers you - fix itit’s called a learning experienceand will make you a better persontm
  13. Google Goit’s not just for Google
  14. meet Gordon
  15. he’s a gopher
  16. of very few words
  17. who lives at google
  18. package mainimport "fmt"const HELLO string = "hello"var WORLD string = "world"func main() { fmt.Println(HELLO, WORLD)}
  19. package mainimport "fmt"const HELLO string = "hello"var WORLD string = "world"func main() { fmt.Println(HELLO, WORLD)}
  20. package mainimport "fmt"const HELLO string = "hello"var WORLD string = "world"func main() { fmt.Println(HELLO, WORLD)}
  21. package mainimport "fmt"const HELLO string = "hello"var WORLD string = "world"func main() { fmt.Println(HELLO, WORLD)}
  22. packageorganisation import var, const, typedeclaration func, interface, map, struct, chan if ... else switch ... case ... fallthrough ... default select ... casecontrol flow for for ... range break, continue go, goto, defer, return
  23. boolean, numeric, array value structure, interfacereference pointer, slice, string, map, channelinvocation function, method, closure
  24. Go Rubycompilation static AOT runtime mutable memory garbage collected syntax minimalist humanistic strong dynamic type embedding inheritance dispatch procedural invocation message passingsemantics statements expressions
  25. Ruby typing is tricksy lies we tell ourself about type
  26. superclass modulesclass modules message instance
  27. superclass modules class modulestype asserted instance
  28. instance inherited class class expressed type modules
  29. instance inherited class class expressed type modules
  30. instance inherited class class expressed type modules
  31. instance inherited class class expressed type modules
  32. class Counter attr_writer :count def initialize @count = 0 end def Tick @count += 1 endendclass DoubleCounter < Counter def Tick super @count += 1 endendn = new(DoubleCounter)puts n.Tickputs n.superclass.Tick
  33. class Counter attr_writer :count def initialize @count = 0 end def Tick @count += 1 endendclass DoubleCounter < Counter def Tick super @count += 1 endendn = new(DoubleCounter)puts n.Tickputs n.superclass.Tick
  34. class Counter attr_writer :count def initialize @count = 0 end def Tick @count += 1 endendclass DoubleCounter < Counter def Tick super @count += 1 endendn = new(DoubleCounter)puts n.Tickputs n.superclass.Tick
  35. class Counter attr_writer :count def initialize @count = 0 end def Tick @count += 1 endendclass DoubleCounter < Counter def Tick super @count += 1 endendn = new(DoubleCounter)puts n.Tickputs n.superclass.Tick
  36. class Counter attr_writer :count def initialize @count = 0 end def Tick @count += 1 endendclass DoubleCounter < Counter def Tick super @count += 1 endendn = new(DoubleCounter)puts n.Tickputs n.superclass.Tick
  37. class Counter attr_writer :count def initialize @count = 0 end def Tick @count += 1 endendclass DoubleCounter < Counter def Tick super @count += 1 endendn = new(DoubleCounter)puts n.Tickputs n.superclass.Tick
  38. down a rabbit holeinstances are their own classes
  39. down a rabbit holeinstances are their own classesand all classes are mutable at runtime
  40. down a rabbit holeinstances are their own classesall classes are mutable at runtimeso inheritance pathways can be altered
  41. down a rabbit holeinstances are their own classesand all classes are mutable at runtimeso inheritance pathways can be alteredmaking Ruby very flexible
  42. down a rabbit holeinstances are their own classesand all classes are mutable at runtimeso inheritance pathways can be alteredmaking Ruby very flexibleat the cost of type uncertainty
  43. down a rabbit holeinstances are their own classesand all classes are mutable at runtimeso inheritance pathways can be alteredmaking Ruby very flexibleat the cost of type uncertaintywhich really bugs computer scientists
  44. type in Go is safetmclearly defined areas of doubt and uncertainty
  45. memory method layout set static type embedded types
  46. memory method layout set static type embedded types
  47. memory method layout set static type embedded types
  48. memory method layout set static type embedded types
  49. package Integertype Int intfunc (i *Int) Add(x int) { *i += Int(x)}
  50. package Integertype Int intfunc (i *Int) Add(x int) { *i += Int(x)}
  51. package Integertype Int intfunc (i *Int) Add(x int) { *i += Int(x)}
  52. package Integertype Int intfunc (i *Int) Add(x int) { *i += Int(x)}
  53. type Buffer []Intfunc (b Buffer) Swap(i, j int) { b[i], b[j] = b[j], b[i]}func (b Buffer) Clone() Buffer { s := make(Buffer, len(b)) copy(s, b) return s}func (b Buffer) Move(i, n int) { if n > len(b) - i { n = len(b) - i } segment_to_move := b[:i].Clone() copy(b, b[i:i + n]) copy(b[n:i + n], segment_to_move)}
  54. type Buffer []Intfunc (b Buffer) Swap(i, j int) { b[i], b[j] = b[j], b[i]}func (b Buffer) Clone() Buffer { s := make(Buffer, len(b)) copy(s, b) return s}func (b Buffer) Move(i, n int) { if n > len(b) - i { n = len(b) - i } segment_to_move := b[:i].Clone() copy(b, b[i:i + n]) copy(b[n:i + n], segment_to_move)}
  55. type Buffer []Intfunc (b Buffer) Swap(i, j int) { b[i], b[j] = b[j], b[i]}func (b Buffer) Clone() Buffer { s := make(Buffer, len(b)) copy(s, b) return s}func (b Buffer) Move(i, n int) { if n > len(b) - i { n = len(b) - i } segment_to_move := b[:i].Clone() copy(b, b[i:i + n]) copy(b[n:i + n], segment_to_move)}
  56. package mainimport "fmt"import "Integer"func main() { i := Integer.Buffer{0, 1, 2, 3, 4, 5} b := i.Clone() b.Swap(1, 2) b.Move(3, 2) b[0].Add(3) produces: fmt.Printf("b[0:2] = %vn", b[:2]) b[0:2] = [6 4]}
  57. package mainimport "fmt"import "Integer"func main() { i := Integer.Buffer{0, 1, 2, 3, 4, 5} b := i.Clone() b.Swap(1, 2) b.Move(3, 2) b[0].Add(3) produces: fmt.Printf(“b[0:2] = %vn”, b[:2]) b[0:2] = [6 4]}
  58. package mainimport "fmt"import "Integer"func main() { i := Integer.Buffer{0, 1, 2, 3, 4, 5} b := i.Clone() b.Swap(1, 2) b.Move(3, 2) b[0].Add(3) produces: fmt.Printf("b[0:2] = %vn", b[:2]) b[0:2] = [6 4]}
  59. package mainimport "fmt"import "Integer"func main() { i := Integer.Buffer{0, 1, 2, 3, 4, 5} b := i.Clone() b.Swap(1, 2) b.Move(3, 2) b[0].Add(3) produces: fmt.Printf("b[0:2] = %vn", b[:2]) b[0:2] = [6 4]}
  60. package mainimport "fmt"import "Integer"func main() { i := Integer.Buffer{0, 1, 2, 3, 4, 5} b := i.Clone() b.Swap(1, 2) b.Move(3, 2) b[0].Add(3) produces: fmt.Printf("b[0:2] = %vn", b[:2]) b[0:2] = [6 4]}
  61. package Vectorimport . "Integer"type Vector struct { Buffer}func (v *Vector) Clone() *Vector { return &Vector{v.Buffer.Clone()}}func (v *Vector) Slice(i, j int) Buffer { return v.Buffer[i:j]}
  62. package Vectorimport . "Integer"type Vector struct { Buffer}func (v *Vector) Clone() *Vector { return &Vector{v.Buffer.Clone()}}func (v *Vector) Slice(i, j int) Buffer { return v.Buffer[i:j]}
  63. package Vectorimport . "Integer"type Vector struct { Buffer}func (v *Vector) Clone() *Vector { return &Vector{v.Buffer.Clone()}}func (v *Vector) Slice(i, j int) Buffer { return v.Buffer[i:j]}
  64. package Vectorimport . "Integer"type Vector struct { Buffer}func (v *Vector) Clone() *Vector { return &Vector{v.Buffer.Clone()}}func (v *Vector) Slice(i, j int) Buffer { return v.Buffer[i:j]}
  65. package Vectorimport . "Integer"type Vector struct { Buffer}func (v *Vector) Clone() *Vector { return &Vector{v.Buffer.Clone()}}func (v *Vector) Slice(i, j int) Buffer { return v.Buffer[i:j]}
  66. type Adder interface { Add(j int) Subtract(j int) Result() interface{} Reset()}
  67. type Adder interface { Add(j int) Subtract(j int) Result() interface{} Reset()}
  68. type Adder interface { Add(j int) Subtract(j int) Result() interface{} Reset()}
  69. type IAdder intfunc (i IAdder) Add(j int) { i[0] += i[j]}func (i IAdder) Subtract(j int) { i[0] -= i[j]}func (i IAdder) Result() interface{} { return i[0]}func (i IAdder) Reset() { i[0] = *new(int)}func (i IAdder) Increment() { i[0]++}
  70. type IAdder intfunc (i IAdder) Add(j int) { i[0] += i[j]}func (i IAdder) Subtract(j int) { i[0] -= i[j]}func (i IAdder) Result() interface{} { return i[0]}func (i IAdder) Reset() { i[0] = *new(int)}func (i IAdder) Increment() { i[0]++}
  71. type IAdder intfunc (i IAdder) Add(j int) { i[0] += i[j]}func (i IAdder) Subtract(j int) { i[0] -= i[j]}func (i IAdder) Result() interface{} { return i[0]}func (i IAdder) Reset() { i[0] = *new(int)}func (i IAdder) Increment() { i[0]++}
  72. type FAdder []float32func (f FAdder) Add(j int) { f[0] += f[j]}func (f FAdder) Subtract(j int) { f[0] -= f[j]}func (f FAdder) Result() interface{} { return f[0]}func (f FAdder) Reset() { f[0] = 0}
  73. type FAdder []float32func (f FAdder) Add(j int) { f[0] += f[j]}func (f FAdder) Subtract(j int) { f[0] -= f[j]}func (f FAdder) Result() interface{} { return f[0]}func (f FAdder) Reset() { f[0] = 0}
  74. type FAdder []float32func (f FAdder) Add(j int) { f[0] += f[j]}func (f FAdder) Subtract(j int) { f[0] -= f[j]}func (f FAdder) Result() interface{} { return f[0]}func (f FAdder) Reset() { f[0] = 0}
  75. func TestAdder(t *testing.T) { var a Adder a = IAdder{0, 1, 2} a.Add(1) if i.Result().(int) != 1 { t.Fatalf("IAdder::Add(1) %v != %v", a.Result(), 1) } a.Subtract(2) if a.Result().(int) != -1 { t.Fatalf("IAdder::Subtract(2) %v != %v", a.Result(), -1) } a = FAdder{0.0, 1.0, 2.0} a.Add(1) if a.Result().(float32) != 1.0 { t.Fatalf("FAdder::Add(1) %v != %v", a.Result(), 1.0) }}
  76. func TestAdder(t *testing.T) { var a Adder a = IAdder{0, 1, 2} a.Add(1) if i.Result().(int) != 1 { t.Fatalf("IAdder::Add(1) %v != %v", a.Result(), 1) } a.Subtract(2) if a.Result().(int) != -1 { t.Fatalf("IAdder::Subtract(2) %v != %v", a.Result(), -1) } a = FAdder{0.0, 1.0, 2.0} a.Add(1) if a.Result().(float32) != 1.0 { t.Fatalf("FAdder::Add(1) %v != %v", a.Result(), 1.0) }}
  77. func TestAdder(t *testing.T) { var a Adder a = IAdder{0, 1, 2} a.Add(1) if i.Result().(int) != 1 { t.Fatalf("IAdder::Add(1) %v != %v", a.Result(), 1) } a.Subtract(2) if a.Result().(int) != -1 { t.Fatalf("IAdder::Subtract(2) %v != %v", a.Result(), -1) } a = FAdder{0.0, 1.0, 2.0} a.Add(1) if a.Result().(float32) != 1.0 { t.Fatalf("FAdder::Add(1) %v != %v", a.Result(), 1.0) }}
  78. func TestAdder(t *testing.T) { var a Adder a = IAdder{0, 1, 2} a.Add(1) if i.Result().(int) != 1 { t.Fatalf("IAdder::Add(1) %v != %v", a.Result(), 1) } a.Subtract(2) if a.Result().(int) != -1 { t.Fatalf("IAdder::Subtract(2) %v != %v", a.Result(), -1) } a = FAdder{0.0, 1.0, 2.0} a.Add(1) if a.Result().(float32) != 1.0 { t.Fatalf("FAdder::Add(1) %v != %v", a.Result(), 1.0) }}
  79. func TestAdder(t *testing.T) { var a Adder a = IAdder{0, 1, 2} a.Add(1) if i.Result().(int) != 1 { t.Fatalf("IAdder::Add(1) %v != %v", a.Result(), 1) } a.Subtract(2) if a.Result().(int) != -1 { t.Fatalf("IAdder::Subtract(2) %v != %v", a.Result(), -1) } a = FAdder{0.0, 1.0, 2.0} a.Add(1) if a.Result().(float32) != 1.0 { t.Fatalf("FAdder::Add(1) %v != %v", a.Result(), 1.0) }}
  80. func TestAdder(t *testing.T) { var a Adder a = IAdder{0, 1, 2} a.Add(1) if i.Result().(int) != 1 { t.Fatalf("IAdder::Add(1) %v != %v", a.Result(), 1) } a.Subtract(2) if a.Result().(int) != -1 { t.Fatalf("IAdder::Subtract(2) %v != %v", a.Result(), -1) } a = FAdder{0.0, 1.0, 2.0} a.Add(1) if a.Result().(float32) != 1.0 { t.Fatalf("FAdder::Add(1) %v != %v", a.Result(), 1.0) }}
  81. func TestAdder(t *testing.T) { var a Adder a = IAdder{0, 1, 2} a.Add(1) if i.Result().(int) != 1 { t.Fatalf("IAdder::Add(1) %v != %v", a.Result(), 1) } a.Subtract(2) if a.Result().(int) != -1 { t.Fatalf("IAdder::Subtract(2) %v != %v", a.Result(), -1) } a = FAdder{0.0, 1.0, 2.0} a.Add(1) if a.Result().(float32) != 1.0 { t.Fatalf("FAdder::Add(1) %v != %v", a.Result(), 1.0) }}
  82. down a rabbit holean object has known static type
  83. down a rabbit holean object has known static typethis fixed type is determined at linking
  84. down a rabbit holean object has known static typethis fixed type is determined at linkingno new types can be created at runtime
  85. down a rabbit holean object has known static typethis fixed type is determined at linkingno new types can be created at runtimeso dynamism is bounded to a fixed set
  86. down a rabbit holean object has known static typethis fixed type is determined at linkingno new types can be created at runtimeso dynamism is bounded to this fixed setand computer scientists are happier
  87. unit tests as REPL testing that doesn’t suck
  88. func (b Buffer) Eq(o Buffer) (r bool) { if len(b) == len(o) { for i := len(b) - 1; i > 0; i-- { if b[i] != o[i] { return } } r = true } return}
  89. func (b Buffer) Eq(o Buffer) (r bool) { if len(b) == len(o) { for i := len(b) - 1; i > 0; i-- { if b[i] != o[i] { return } } r = true } return}
  90. func (b Buffer) Eq(o Buffer) (r bool) { if len(b) == len(o) { for i := len(b) - 1; i > 0; i-- { if b[i] != o[i] { return } } r = true } return}
  91. func (b Buffer) Eq(o Buffer) (r bool) { if len(b) == len(o) { for i := len(b) - 1; i > 0; i-- { if b[i] != o[i] { return } } r = true } return}
  92. func (b Buffer) Eq(o Buffer) (r bool) { if len(b) == len(o) { for i := len(b) - 1; i > 0; i-- { if b[i] != o[i] { return } } r = true } return}
  93. func (b Buffer) Eq(o Buffer) (r bool) { if len(b) == len(o) { for i := len(b) - 1; i > 0; i-- { if b[i] != o[i] { return } } r = true } return}
  94. func (b Buffer) Eq(o Buffer) (r bool) { if len(b) == len(o) { for i := len(b) - 1; i > 0; i-- { if b[i] != o[i] { return } } r = true } return}
  95. package Vectorimport "testing"func TestVectorSwap(t *testing.T) { i := Vector{Buffer{0, 1, 2, 3, 4, 5}} v := i.Clone() v.Swap(1, 2) r := Vector{Buffer{0, 2, 1, 3, 4, 5}} switch { case !v.Eq(r.Buffer): fallthrough case !v.Buffer.Eq(r.Buffer): t.Fatalf("b[0:5] = %v", v) }}
  96. package Vectorimport "testing"func TestVectorSwap(t *testing.T) { i := Vector{Buffer{0, 1, 2, 3, 4, 5}} v := i.Clone() v.Swap(1, 2) r := Vector{Buffer{0, 2, 1, 3, 4, 5}} switch { case !v.Eq(r.Buffer): fallthrough case !v.Buffer.Eq(r.Buffer): t.Fatalf("b[0:5] = %v", v) }}
  97. package Vectorimport "testing"func TestVectorSwap(t *testing.T) { i := Vector{Buffer{0, 1, 2, 3, 4, 5}} v := i.Clone() v.Swap(1, 2) r := Vector{Buffer{0, 2, 1, 3, 4, 5}} switch { case !v.Eq(r.Buffer): fallthrough case !v.Buffer.Eq(r.Buffer): t.Fatalf("b[0:5] = %v", v) }}
  98. package Vectorimport "testing"func TestVectorSwap(t *testing.T) { i := Vector{Buffer{0, 1, 2, 3, 4, 5}} v := i.Clone() v.Swap(1, 2) r := Vector{Buffer{0, 2, 1, 3, 4, 5}} switch { case !v.Eq(r.Buffer): fallthrough case !v.Buffer.Eq(r.Buffer): t.Fatalf("b[0:5] = %v", v) }}
  99. package Vectorimport "testing"func TestVectorSwap(t *testing.T) { i := Vector{Buffer{0, 1, 2, 3, 4, 5}} v := i.Clone() v.Swap(1, 2) r := Vector{Buffer{0, 2, 1, 3, 4, 5}} switch { case !v.Eq(r.Buffer): fallthrough case !v.Buffer.Eq(r.Buffer): t.Fatalf("b[0:5] = %v", v) }}
  100. package Vectorimport "testing"func TestVectorSwap(t *testing.T) { i := Vector{Buffer{0, 1, 2, 3, 4, 5}} v := i.Clone() v.Swap(1, 2) r := Vector{Buffer{0, 2, 1, 3, 4, 5}} switch { case !v.Eq(r.Buffer): fallthrough case !v.Buffer.Eq(r.Buffer): t.Fatalf("b[0:5] = %v", v) }}
  101. package Vectorimport "testing"func TestVectorSwap(t *testing.T) { i := Vector{Buffer{0, 1, 2, 3, 4, 5}} v := i.Clone() v.Swap(1, 2) r := Vector{Buffer{0, 2, 1, 3, 4, 5}} switch { case !v.Eq(r.Buffer): fallthrough case !v.Buffer.Eq(r.Buffer): t.Fatalf("b[0:5] = %v", v) }}
  102. package Vectorimport "testing"func TestVectorSwap(t *testing.T) { i := Vector{Buffer{0, 1, 2, 3, 4, 5}} v := i.Clone() v.Swap(1, 2) r := Vector{Buffer{0, 2, 1, 3, 4, 5}} switch { case !v.Eq(r.Buffer): fallthrough case !v.Buffer.Eq(r.Buffer): t.Fatalf("b[0:5] = %v", v) }}
  103. include $(GOROOT)/src/Make.incTARG=integerGOFILES= integer.go vector.goinclude $(GOROOT)/src/Make.pkg
  104. package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) { v := Vector{Buffer{0, 1, 2, 3, 4, 5}} for i := 0; i < b.N; i++ { _ = v.Clone() }}func BenchmarkVectorSwap(b *testing.B) { b.StopTimer() v := Vector{Buffer{0, 1, 2, 3, 4, 5}} b.StartTimer() for i := 0; i < b.N; i++ { v.Swap(1, 2) }}
  105. package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) { v := Vector{Buffer{0, 1, 2, 3, 4, 5}} for i := 0; i < b.N; i++ { _ = v.Clone() }}func BenchmarkVectorSwap(b *testing.B) { b.StopTimer() v := Vector{Buffer{0, 1, 2, 3, 4, 5}} b.StartTimer() for i := 0; i < b.N; i++ { v.Swap(1, 2) }}
  106. package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) { v := Vector{Buffer{0, 1, 2, 3, 4, 5}} for i := 0; i < b.N; i++ { _ = v.Clone() }}func BenchmarkVectorSwap(b *testing.B) { b.StopTimer() v := Vector{Buffer{0, 1, 2, 3, 4, 5}} b.StartTimer() for i := 0; i < b.N; i++ { v.Swap(1, 2) }}
  107. package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) { v := Vector{Buffer{0, 1, 2, 3, 4, 5}} for i := 0; i < b.N; i++ { _ = v.Clone() }}func BenchmarkVectorSwap(b *testing.B) { b.StopTimer() v := Vector{Buffer{0, 1, 2, 3, 4, 5}} b.StartTimer() for i := 0; i < b.N; i++ { v.Swap(1, 2) }}
  108. package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) { v := Vector{Buffer{0, 1, 2, 3, 4, 5}} for i := 0; i < b.N; i++ { _ = v.Clone() }}func BenchmarkVectorSwap(b *testing.B) { b.StopTimer() v := Vector{Buffer{0, 1, 2, 3, 4, 5}} b.StartTimer() for i := 0; i < b.N; i++ { v.Swap(1, 2) }}
  109. package Vectorimport "testing"import "vector"func BenchmarkVectorClone6(b *testing.B) { v := Vector{Buffer{0, 1, 2, 3, 4, 5}} for i := 0; i < b.N; i++ { _ = v.Clone() }}func BenchmarkVectorSwap(b *testing.B) { b.StopTimer() v := Vector{Buffer{0, 1, 2, 3, 4, 5}} b.StartTimer() for i := 0; i < b.N; i++ { v.Swap(1, 2) }}
  110. $ gotest -bench="Benchmark"rm -f _test/scripts.a6g -o _gotest_.6 integer.go vector.go nominal_typing_test.goembedded_typing_benchmark_test.go embedded_typing_test.gorm -f _test/scripts.agopack grc _test/scripts.a _gotest_.6PASSinteger.BenchmarkVectorSwap 200000000 8 ns/opinteger.BenchmarkVectorClone6 10000000 300 ns/op
  111. $ gotest -bench="Benchmark"rm -f _test/scripts.a6g -o _gotest_.6 integer.go vector.go nominal_typing_test.goembedded_typing_benchmark_test.go embedded_typing_test.gorm -f _test/scripts.agopack grc _test/scripts.a _gotest_.6PASSinteger.BenchmarkVectorSwap 200000000 8 ns/opinteger.BenchmarkVectorClone6 10000000 300 ns/op
  112. $ gotest -bench="Benchmark"rm -f _test/scripts.a6g -o _gotest_.6 integer.go vector.go nominal_typing_test.goembedded_typing_benchmark_test.go embedded_typing_test.gorm -f _test/scripts.agopack grc _test/scripts.a _gotest_.6PASSinteger.BenchmarkVectorSwap 200000000 8 ns/opinteger.BenchmarkVectorClone6 10000000 300 ns/op
  113. $ gotest -bench="Benchmark"rm -f _test/scripts.a6g -o _gotest_.6 integer.go vector.go nominal_typing_test.goembedded_typing_benchmark_test.go embedded_typing_test.gorm -f _test/scripts.agopack grc _test/scripts.a _gotest_.6PASSinteger.BenchmarkVectorSwap 200000000 8 ns/opinteger.BenchmarkVectorClone6 10000000 300 ns/op
  114. $ gotest -bench="Benchmark"rm -f _test/scripts.a6g -o _gotest_.6 integer.go vector.go nominal_typing_test.goembedded_typing_benchmark_test.go embedded_typing_test.gorm -f _test/scripts.agopack grc _test/scripts.a _gotest_.6PASSinteger.BenchmarkVectorSwap 200000000 8 ns/opinteger.BenchmarkVectorClone6 10000000 300 ns/op
  115. exceptional funbecause Go doesn’t have exceptions - honest!
  116. func Throw() { panic(nil)}func Catch(f func()) { defer func() { if x := recover(); x != nil { panic(x) } }() f()}func CatchAll(f func()) { defer func() { recover() }() f()}
  117. func Throw() { panic(nil)}func Catch(f func()) { defer func() { if x := recover(); x != nil { panic(x) } }() f()}func CatchAll(f func()) { defer func() { recover() }() f()}
  118. func Throw() { panic(nil)}func Catch(f func()) { defer func() { if x := recover(); x != nil { panic(x) } }() f()}func CatchAll(f func()) { defer func() { recover() }() f()}
  119. func Throw() { panic(nil)}func Catch(f func()) { defer func() { if x := recover(); x != nil { panic(x) } }() f()}func CatchAll(f func()) { defer func() { recover() }() f()}
  120. func Throw() { panic(nil)}func Catch(f func()) { defer func() { if x := recover(); x != nil { panic(x) } }() f()}func CatchAll(f func()) { defer func() { recover() }() f()}
  121. func Throw() { panic(nil)}func Catch(f func()) { defer func() { if x := recover(); x != nil { panic(x) } }() f()}func CatchAll(f func()) { defer func() { recover() }() f()}
  122. func Throw() { panic(nil)}func Catch(f func()) { defer func() { if x := recover(); x != nil { panic(x) } }() f()}func CatchAll(f func()) { defer func() { recover() }() f()}
  123. func Throw() { panic(nil)}func Catch(f func()) { defer func() { if x := recover(); x != nil { panic(x) } }() f()}func CatchAll(f func()) { defer func() { recover() }() f()}
  124. func Throw() { panic(nil)}func Catch(f func()) { defer func() { if x := recover(); x != nil { panic(x) } }() f()}func CatchAll(f func()) { defer func() { recover() }() f()}
  125. func Throw() { panic(nil)}func Catch(f func()) { defer func() { if x := recover(); x != nil { panic(x) } }() f()}func CatchAll(f func()) { defer func() { recover() }() f()}
  126. func throwsPanic(f func()) (b bool) { defer func() { if x := recover(); x != nil { b = true } }() f() return}
  127. func throwsPanic(f func()) (b bool) { defer func() { if x := recover(); x != nil { b = true } }() f() return}
  128. func throwsPanic(f func()) (b bool) { defer func() { if x := recover(); x != nil { b = true } }() f() return}
  129. func throwsPanic(f func()) (b bool) { defer func() { if x := recover(); x != nil { b = true } }() f() return}
  130. func throwsPanic(f func()) (b bool) { defer func() { if x := recover(); x != nil { b = true } }() f() return}
  131. func throwsPanic(f func()) (b bool) { defer func() { if x := recover(); x != nil { b = true } }() f() return}
  132. func throwsPanic(f func()) (b bool) { defer func() { if x := recover(); x != nil { b = true } }() f() return}
  133. func throwsPanic(f func()) (b bool) { defer func() { if x := recover(); x != nil { b = true } }() f() return}
  134. import "fmt"import "path"import "runtime"func StackTrace() { var stack_trace []uintptr var my_path string runtime.Callers(1, stack_trace) for i, u := range stack_trace { if f := runtime.FuncForPC(u); f != nil { file, line := f.FileLine(u) switch filepath, filename := path.Split(file); { case i == 0: my_path = filepath case my_path != filepath: fmt.Printf("%v:%v", filename, line) } } else { fmt.Println("(unknown)") } }}
  135. import "fmt"import "path"import "runtime"func StackTrace() { var stack_trace []uintptr var my_path string runtime.Callers(1, stack_trace) for i, u := range stack_trace { if f := runtime.FuncForPC(u); f != nil { file, line := f.FileLine(u) switch filepath, filename := path.Split(file); { case i == 0: my_path = filepath case my_path != filepath: fmt.Printf("%v:%v", filename, line) } } else { fmt.Println("(unknown)") } }}
  136. import "fmt"import "path"import "runtime"func StackTrace() { var stack_trace []uintptr var my_path string runtime.Callers(1, stack_trace) for i, u := range stack_trace { if f := runtime.FuncForPC(u); f != nil { file, line := f.FileLine(u) switch filepath, filename := path.Split(file); { case i == 0: my_path = filepath case my_path != filepath: fmt.Printf("%v:%v", filename, line) } } else { fmt.Println("(unknown)") } }}
  137. import "fmt"import "path"import "runtime"func StackTrace() { var stack_trace []uintptr var my_path string runtime.Callers(1, stack_trace) for i, u := range stack_trace { if f := runtime.FuncForPC(u); f != nil { file, line := f.FileLine(u) switch filepath, filename := path.Split(file); { case i == 0: my_path = filepath case my_path != filepath: fmt.Printf("%v:%v", filename, line) } } else { fmt.Println("(unknown)") } }}
  138. import "fmt"import "path"import "runtime"func StackTrace() { var stack_trace []uintptr var my_path string runtime.Callers(1, stack_trace) for i, u := range stack_trace { if f := runtime.FuncForPC(u); f != nil { file, line := f.FileLine(u) switch filepath, filename := path.Split(file); { case i == 0: my_path = filepath case my_path != filepath: fmt.Printf("%v:%v", filename, line) } } else { fmt.Println("(unknown)") } }}
  139. import "fmt"import "path"import "runtime"func StackTrace() { var stack_trace []uintptr var my_path string runtime.Callers(1, stack_trace) for i, u := range stack_trace { if f := runtime.FuncForPC(u); f != nil { file, line := f.FileLine(u) switch filepath, filename := path.Split(file); { case i == 0: my_path = filepath case my_path != filepath: fmt.Printf("%v:%v", filename, line) } } else { fmt.Println("(unknown)") } }}
  140. import "fmt"import "path"import "runtime"func StackTrace() { var stack_trace []uintptr var my_path string runtime.Callers(1, stack_trace) for i, u := range stack_trace { if f := runtime.FuncForPC(u); f != nil { file, line := f.FileLine(u) switch filepath, filename := path.Split(file); { case i == 0: my_path = filepath case my_path != filepath: fmt.Printf("%v:%v", filename, line) } } else { fmt.Println("(unknown)") } }}
  141. import "fmt"import "path"import "runtime"func StackTrace() { var stack_trace []uintptr var my_path string runtime.Callers(1, stack_trace) for i, u := range stack_trace { if f := runtime.FuncForPC(u); f != nil { file, line := f.FileLine(u) switch filepath, filename := path.Split(file); { case i == 0: my_path = filepath case my_path != filepath: fmt.Printf("%v:%v", filename, line) } } else { fmt.Println("(unknown)") } }}
  142. import "fmt"import "path"import "runtime"func StackTrace() { var stack_trace []uintptr var my_path string runtime.Callers(1, stack_trace) for i, u := range stack_trace { if f := runtime.FuncForPC(u); f != nil { file, line := f.FileLine(u) switch filepath, filename := path.Split(file); { case i == 0: my_path = filepath case my_path != filepath: fmt.Printf("%v:%v", filename, line) } } else { fmt.Println("(unknown)") } }}
  143. import "fmt"import "path"import "runtime"func StackTrace() { var stack_trace []uintptr var my_path string runtime.Callers(1, stack_trace) for i, u := range stack_trace { if f := runtime.FuncForPC(u); f != nil { file, line := f.FileLine(u) switch filepath, filename := path.Split(file); { case i == 0: my_path = filepath case my_path != filepath: fmt.Printf("%v:%v", filename, line) } } else { fmt.Println("(unknown)") } }}
  144. import "fmt"import "path"import "runtime"func StackTrace() { var stack_trace []uintptr var my_path string runtime.Callers(1, stack_trace) for i, u := range stack_trace { if f := runtime.FuncForPC(u); f != nil { file, line := f.FileLine(u) switch filepath, filename := path.Split(file); { case i == 0: my_path = filepath case my_path != filepath: fmt.Printf("%v:%v", filename, line) } } else { fmt.Println("(unknown)") } }}
  145. reflections on Godynamism through run-time type manipulation
  146. package generaliseimport "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := reflect.ValueOf(i); v.Kind() { case reflect.Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = reflect.MakeSlice(v.Type(), l, l).Interface() case reflect.Map: n = reflect.MakeMap(v.Type()).Interface() } return}
  147. package generaliseimport "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := reflect.ValueOf(i); v.Kind() { case reflect.Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = reflect.MakeSlice(v.Type(), l, l).Interface() case reflect.Map: n = reflect.MakeMap(v.Type()).Interface() } return}
  148. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  149. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  150. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  151. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  152. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  153. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  154. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  155. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  156. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  157. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  158. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  159. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  160. package generaliseimport . "reflect"func Allocate(i interface{}, limit... int) (n interface{}) { switch v := ValueOf(i); v.Kind() { case Slice: l := v.Cap() if len(limit) > 0 { l = limit[0] } n = MakeSlice(v.Type(), l, l).Interface() case Map: n = MakeMap(v.Type()).Interface() } return}
  161. func TestAllocate(t *testing.T) { var s2 []int s1 := []int{0, 1, 2} m := map[int] int{1: 1, 2: 2, 3: 3} switch { case throwsPanic(func() { s2 = Allocate(s1, 1).([]int) }): t.Fatal("Unable to allocate new slice") case len(s2) != 1 || cap(s2) != 1: t.Fatalf("New slice should be %v not %v", make([]int, 0, 1), s2) case throwsPanic(func() { Allocate(m) }): t.Fatal("Unable to allocate new map") }}
  162. func TestAllocate(t *testing.T) { var s2 []int s1 := []int{0, 1, 2} m := map[int] int{1: 1, 2: 2, 3: 3} switch { case throwsPanic(func() { s2 = Allocate(s1, 1).([]int) }): t.Fatal("Unable to allocate new slice") case len(s2) != 1 || cap(s2) != 1: t.Fatalf("New slice should be %v not %v", make([]int, 0, 1), s2) case throwsPanic(func() { Allocate(m) }): t.Fatal("Unable to allocate new map") }}
  163. func TestAllocate(t *testing.T) { var s2 []int s1 := []int{0, 1, 2} m := map[int] int{1: 1, 2: 2, 3: 3} switch { case throwsPanic(func() { s2 = Allocate(s1, 1).([]int) }): t.Fatal("Unable to allocate new slice") case len(s2) != 1 || cap(s2) != 1: t.Fatalf("New slice should be %v not %v", make([]int, 0, 1), s2) case throwsPanic(func() { Allocate(m) }): t.Fatal("Unable to allocate new map") }}
  164. func TestAllocate(t *testing.T) { var s2 []int s1 := []int{0, 1, 2} m := map[int] int{1: 1, 2: 2, 3: 3} switch { case throwsPanic(func() { s2 = Allocate(s1, 1).([]int) }): t.Fatal("Unable to allocate new slice") case len(s2) != 1 || cap(s2) != 1: t.Fatalf("New slice should be %v not %v", make([]int, 0, 1), s2) case throwsPanic(func() { Allocate(m) }): t.Fatal("Unable to allocate new map") }}
  165. func TestAllocate(t *testing.T) { var s2 []int s1 := []int{0, 1, 2} m := map[int] int{1: 1, 2: 2, 3: 3} switch { case throwsPanic(func() { s2 = Allocate(s1, 1).([]int) }): t.Fatal("Unable to allocate new slice") case len(s2) != 1 || cap(s2) != 1: t.Fatalf("New slice should be %v not %v", make([]int, 0, 1), s2) case throwsPanic(func() { Allocate(m) }): t.Fatal("Unable to allocate new map") }}
  166. func TestAllocate(t *testing.T) { var s2 []int s1 := []int{0, 1, 2} m := map[int] int{1: 1, 2: 2, 3: 3} switch { case throwsPanic(func() { s2 = Allocate(s1, 1).([]int) }): t.Fatal("Unable to allocate new slice") case len(s2) != 1 || cap(s2) != 1: t.Fatalf("New slice should be %v not %v", make([]int, 0, 1), s2) case throwsPanic(func() { Allocate(m) }): t.Fatal("Unable to allocate new map") }}
  167. func TestAllocate(t *testing.T) { var s2 []int s1 := []int{0, 1, 2} m := map[int] int{1: 1, 2: 2, 3: 3} switch { case throwsPanic(func() { s2 = Allocate(s1, 1).([]int) }): t.Fatal("Unable to allocate new slice") case len(s2) != 1 || cap(s2) != 1: t.Fatalf("New slice should be %v not %v", make([]int, 0, 1), s2) case throwsPanic(func() { Allocate(m) }): t.Fatal("Unable to allocate new map") }}
  168. func TestAllocate(t *testing.T) { var s2 []int s1 := []int{0, 1, 2} m := map[int] int{1: 1, 2: 2, 3: 3} switch { case throwsPanic(func() { s2 = Allocate(s1, 1).([]int) }): t.Fatal("Unable to allocate new slice") case len(s2) != 1 || cap(s2) != 1: t.Fatalf("New slice should be %v not %v", make([]int, 0, 1), s2) case throwsPanic(func() { Allocate(m) }): t.Fatal("Unable to allocate new map") }}
  169. func TestAllocate(t *testing.T) { var s2 []int s1 := []int{0, 1, 2} m := map[int] int{1: 1, 2: 2, 3: 3} switch { case throwsPanic(func() { s2 = Allocate(s1, 1).([]int) }): t.Fatal("Unable to allocate new slice") case len(s2) != 1 || cap(s2) != 1: t.Fatalf("New slice should be %v not %v", make([]int, 0, 1), s2) case throwsPanic(func() { Allocate(m) }): t.Fatal("Unable to allocate new map") }}
  170. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  171. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  172. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  173. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  174. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  175. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  176. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  177. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  178. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  179. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  180. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  181. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  182. func Duplicate(i interface{}) (clone interface{}) { if clone = Allocate(i); clone != nil { switch clone := ValueOf(clone); clone.Kind() { case Slice: Copy(clone, ValueOf(i)) case Map: m := ValueOf(i) for _, k := range m.Keys() { clone.SetMapIndex(k, m.MapIndex(k)) } } } return}
  183. metallic k.o.sometimes a bit-buffer is just a bit-buffer
  184. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  185. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  186. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  187. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  188. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  189. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  190. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  191. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  192. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  193. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  194. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  195. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  196. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  197. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  198. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  199. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  200. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  201. package rawimport . "reflect"import "unsafe"var _BYTE_SLICE Type = Typeof([]byte(nil))type MemoryBlock interface { ByteSlice() []byte}func valueHeader(v Value) (header *SliceHeader) { if v.IsValid() { s := int(v.Type().Size()) header = &SliceHeader{ v.UnsafeAddr(), s, s } } return}
  202. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  203. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  204. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  205. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  206. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  207. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  208. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  209. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  210. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  211. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  212. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  213. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  214. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  215. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  216. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  217. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  218. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  219. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  220. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  221. func SliceHeader(i interface{}) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.Kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.Type().Elem() Size = int(t.Size()) Align = t.Align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) } return}func Scale(oldHeader *SliceHeader, oldESize, newESize int) (h *SliceHeader) { if oldHeader != nil { s := float64(oldESize) / float64(newESize) h = &SliceHeader{ Data: oldHeader.Data } h.Len = int(float64(oldHeader.Len) * s) h.Cap = int(float64(oldHeader.Cap) * s) } return}
  222. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  223. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  224. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  225. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  226. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  227. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  228. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  229. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  230. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  231. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  232. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  233. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  234. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  235. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  236. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  237. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  238. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}
  239. func ByteSlice(i interface{}) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.ByteSlice() } var header *SliceHeader switch v := ValueOf(i); value.Kind() { case Interface, Ptr: header = valueHeader(v.Elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.Get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.Data, h.Len, h.Len } default: header = valueHeader(v) } return unsafe.Unreflect(_BYTE_SLICE, unsafe.Pointer(header)).([]byte)}

×