SlideShare a Scribd company logo
1 of 408
Go <=> Ruby
 a selection of odd lightning talks



            @feyeleanor

http://slides.games-with-brains.net/
The Wild-Eyed
  Screamer
@feyeleanor
realtime
@feyeleanor
realtime

net working
@feyeleanor
realtime

net working

unix
@feyeleanor
realtime

net working

unix

languages
@feyeleanor
realtime

net working

unix

languages

virtual machines
Hacker 101
this presentation contains code
Hacker 101
this presentation contains code
that code is probably broken
Hacker 101
this presentation contains code
that code is probably broken
if this bothers you - fix it
Hacker 101
this presentation contains code
that code is probably broken
if this bothers you - fix it
it’s called a learning experience
Hacker 101
this presentation contains code
that code is probably broken
if this bothers you - fix it
it’s called a learning experience
and will make you a better persontm
Google Go
it’s not just for Google
meet Gordon
he’s a gopher
of very few words
who lives at google
package main

import "fmt"

const HELLO string = "hello"
var WORLD string = "world"

func main() {
	    fmt.Println(HELLO, WORLD)
}
package main

import "fmt"

const HELLO string = "hello"
var WORLD string = "world"

func main() {
	    fmt.Println(HELLO, WORLD)
}
package main

import "fmt"

const HELLO string = "hello"
var WORLD string = "world"

func main() {
	    fmt.Println(HELLO, WORLD)
}
package main

import "fmt"

const HELLO string = "hello"
var WORLD string = "world"

func main() {
	    fmt.Println(HELLO, WORLD)
}
package
organisation                    import

                           var, const, type
declaration
                 func, interface, map, struct, chan


                                if ... else
               switch ... case ... fallthrough ... default
                             select ... case
control flow                         for
                              for ... range
                           break, continue
                        go, goto, defer, return
boolean, numeric, array

  value
                    structure, interface



reference    pointer, slice, string, map, channel



invocation       function, method, closure
Go                       Ruby

compilation        static AOT            runtime mutable

 memory                     garbage collected

  syntax           minimalist               humanistic

                            strong dynamic
   type
                   embedding               inheritance

 dispatch     procedural invocation      message passing

semantics         statements               expressions
Ruby typing is tricksy
    lies we tell ourself about type
superclass   modules



class        modules


                   message
        instance
superclass   modules



         class        modules


type 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
	   end
end

class DoubleCounter < Counter
	    def Tick
	    	    super
	    	    @count += 1
	    end
end

n = new(DoubleCounter)
puts n.Tick
puts n.superclass.Tick
class Counter
	    attr_writer	   :count

	    def initialize
	    	    @count = 0
	    end

	   def Tick
	   	    @count += 1
	   end
end

class DoubleCounter < Counter
	    def Tick
	    	    super
	    	    @count += 1
	    end
end

n = new(DoubleCounter)
puts n.Tick
puts n.superclass.Tick
class Counter
	    attr_writer	   :count

	    def initialize
	    	    @count = 0
	    end

	   def Tick
	   	    @count += 1
	   end
end

class DoubleCounter < Counter
	    def Tick
	    	    super
	    	    @count += 1
	    end
end

n = new(DoubleCounter)
puts n.Tick
puts n.superclass.Tick
class Counter
	    attr_writer	   :count

	    def initialize
	    	    @count = 0
	    end

	   def Tick
	   	    @count += 1
	   end
end

class DoubleCounter < Counter
	    def Tick
	    	    super
	    	    @count += 1
	    end
end

n = new(DoubleCounter)
puts n.Tick
puts n.superclass.Tick
class Counter
	    attr_writer	   :count

	    def initialize
	    	    @count = 0
	    end

	   def Tick
	   	    @count += 1
	   end
end

class DoubleCounter < Counter
	    def Tick
	    	    super
	    	    @count += 1
	    end
end

n = new(DoubleCounter)
puts n.Tick
puts n.superclass.Tick
class Counter
	    attr_writer	   :count

	    def initialize
	    	    @count = 0
	    end

	   def Tick
	   	    @count += 1
	   end
end

class DoubleCounter < Counter
	    def Tick
	    	    super
	    	    @count += 1
	    end
end

n = new(DoubleCounter)
puts n.Tick
puts n.superclass.Tick
down a rabbit hole
instances are their own classes
down a rabbit hole
instances are their own classes
and all classes are mutable at runtime
down a rabbit hole
instances are their own classes
all classes are mutable at runtime
so inheritance pathways can be altered
down a rabbit hole
instances are their own classes
and all classes are mutable at runtime
so inheritance pathways can be altered
making Ruby very flexible
down a rabbit hole
instances are their own classes
and all classes are mutable at runtime
so inheritance pathways can be altered
making Ruby very flexible
at the cost of type uncertainty
down a rabbit hole
instances are their own classes
and all classes are mutable at runtime
so inheritance pathways can be altered
making Ruby very flexible
at the cost of type uncertainty
which really bugs computer scientists
type in Go is                safetm
clearly 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 Integer

type Int int

func (i *Int) Add(x int) {
	    *i += Int(x)
}
package Integer

type Int int

func (i *Int) Add(x int) {
	    *i += Int(x)
}
package Integer

type Int int

func (i *Int) Add(x int) {
	    *i += Int(x)
}
package Integer

type Int int

func (i *Int) Add(x int) {
	    *i += Int(x)
}
type Buffer []Int

func (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)
}
type Buffer []Int

func (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)
}
type Buffer []Int

func (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)
}
package main

import "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]
}
package main

import "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]
}
package main

import "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]
}
package main

import "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]
}
package main

import "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]
}
package Vector
import . "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]
}
package Vector
import . "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]
}
package Vector
import . "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]
}
package Vector
import . "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]
}
package Vector
import . "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]
}
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 int

func (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]++
}
type IAdder int

func (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]++
}
type IAdder int

func (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]++
}
type FAdder []float32

func (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
}
type FAdder []float32

func (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
}
type FAdder []float32

func (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
}
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)
	   }
}
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)
	   }
}
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)
	   }
}
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)
	   }
}
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)
	   }
}
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)
	   }
}
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)
	   }
}
down a rabbit hole
an object has known static type
down a rabbit hole
an object has known static type
this fixed type is determined at linking
down a rabbit hole
an object has known static type
this fixed type is determined at linking
no new types can be created at runtime
down a rabbit hole
an object has known static type
this fixed type is determined at linking
no new types can be created at runtime
so dynamism is bounded to a fixed set
down a rabbit hole
an object has known static type
this fixed type is determined at linking
no new types can be created at runtime
so dynamism is bounded to this fixed set
and computer scientists are happier
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-- {
	    	     	     if b[i] != o[i] {
	    	     	     	     return
	    	     	     }
	    	     }
	    	     r = true
	    }
	    return
}
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
}
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
}
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
}
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
}
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
}
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
}
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
include $(GOROOT)/src/Make.inc

TARG=integer

GOFILES=
	   integer.go
	   vector.go

include $(GOROOT)/src/Make.pkg
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
package Vector

import "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)
	    }
}
$ gotest -bench="Benchmark"
rm -f _test/scripts.a
6g -o _gotest_.6 integer.go vector.go nominal_typing_test.go
embedded_typing_benchmark_test.go embedded_typing_test.go
rm -f _test/scripts.a
gopack grc _test/scripts.a _gotest_.6
PASS
integer.BenchmarkVectorSwap	 200000000	               8 ns/op
integer.BenchmarkVectorClone6	 10000000	             300 ns/op
$ gotest -bench="Benchmark"
rm -f _test/scripts.a
6g -o _gotest_.6 integer.go vector.go nominal_typing_test.go
embedded_typing_benchmark_test.go embedded_typing_test.go
rm -f _test/scripts.a
gopack grc _test/scripts.a _gotest_.6
PASS
integer.BenchmarkVectorSwap	 200000000	               8 ns/op
integer.BenchmarkVectorClone6	 10000000	             300 ns/op
$ gotest -bench="Benchmark"
rm -f _test/scripts.a
6g -o _gotest_.6 integer.go vector.go nominal_typing_test.go
embedded_typing_benchmark_test.go embedded_typing_test.go
rm -f _test/scripts.a
gopack grc _test/scripts.a _gotest_.6
PASS
integer.BenchmarkVectorSwap	 200000000	               8 ns/op
integer.BenchmarkVectorClone6	 10000000	             300 ns/op
$ gotest -bench="Benchmark"
rm -f _test/scripts.a
6g -o _gotest_.6 integer.go vector.go nominal_typing_test.go
embedded_typing_benchmark_test.go embedded_typing_test.go
rm -f _test/scripts.a
gopack grc _test/scripts.a _gotest_.6
PASS
integer.BenchmarkVectorSwap	 200000000	               8 ns/op
integer.BenchmarkVectorClone6	 10000000	             300 ns/op
$ gotest -bench="Benchmark"
rm -f _test/scripts.a
6g -o _gotest_.6 integer.go vector.go nominal_typing_test.go
embedded_typing_benchmark_test.go embedded_typing_test.go
rm -f _test/scripts.a
gopack grc _test/scripts.a _gotest_.6
PASS
integer.BenchmarkVectorSwap	 200000000	               8 ns/op
integer.BenchmarkVectorClone6	 10000000	             300 ns/op
exceptional fun
because Go doesn’t have exceptions - honest!
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()
}
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()
}
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()
}
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()
}
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()
}
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()
}
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()
}
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()
}
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()
}
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()
}
func throwsPanic(f func()) (b bool) {
	    defer func() {
	    	    if x := recover(); x != nil {
	    	    	     b = true
	    	    }
	    }()
	    f()
	    return
}
func throwsPanic(f func()) (b bool) {
	    defer func() {
	    	    if x := recover(); x != nil {
	    	    	     b = true
	    	    }
	    }()
	    f()
	    return
}
func throwsPanic(f func()) (b bool) {
	    defer func() {
	    	    if x := recover(); x != nil {
	    	    	     b = true
	    	    }
	    }()
	    f()
	    return
}
func throwsPanic(f func()) (b bool) {
	    defer func() {
	    	    if x := recover(); x != nil {
	    	    	     b = true
	    	    }
	    }()
	    f()
	    return
}
func throwsPanic(f func()) (b bool) {
	    defer func() {
	    	    if x := recover(); x != nil {
	    	    	     b = true
	    	    }
	    }()
	    f()
	    return
}
func throwsPanic(f func()) (b bool) {
	    defer func() {
	    	    if x := recover(); x != nil {
	    	    	     b = true
	    	    }
	    }()
	    f()
	    return
}
func throwsPanic(f func()) (b bool) {
	    defer func() {
	    	    if x := recover(); x != nil {
	    	    	     b = true
	    	    }
	    }()
	    f()
	    return
}
func throwsPanic(f func()) (b bool) {
	    defer func() {
	    	    if x := recover(); x != nil {
	    	    	     b = true
	    	    }
	    }()
	    f()
	    return
}
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)")
	   	     }
	   }
}
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)")
	   	     }
	   }
}
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)")
	   	     }
	   }
}
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)")
	   	     }
	   }
}
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)")
	   	     }
	   }
}
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)")
	   	     }
	   }
}
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)")
	   	     }
	   }
}
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)")
	   	     }
	   }
}
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)")
	   	     }
	   }
}
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)")
	   	     }
	   }
}
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)")
	   	     }
	   }
}
reflections on Go
dynamism through run-time type manipulation
package generalise

import "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
}
package generalise

import "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
}
package generalise

import . "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
}
package generalise

import . "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
}
package generalise

import . "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
}
package generalise

import . "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
}
package generalise

import . "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
}
package generalise

import . "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
}
package generalise

import . "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
}
package generalise

import . "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
}
package generalise

import . "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
}
package generalise

import . "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
}
package generalise

import . "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
}
package generalise

import . "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
}
package generalise

import . "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
}
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")
	   }
}
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")
	   }
}
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")
	   }
}
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")
	   }
}
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")
	   }
}
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")
	   }
}
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")
	   }
}
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")
	   }
}
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")
	   }
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
metallic k.o.
sometimes a bit-buffer is just a bit-buffer
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
package raw

import . "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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
go f(){}() / yourself
            /
   map/reduce for all the family
package main
import "fmt"

func main() {
	    var c chan int

	   c = make(chan int)
	   limit := 16
	   go func() {
	   	     for i := limit; i > 0; i-- {
	   	     	     fmt.Print(<-c)           produces:
	   	     }                                 0110011101011010
	   }()
	   for i := limit; i > 0; i-- {
	   	     select {
	   	     case c <- 0:
	   	     case c <- 1:
	   	     }
	   }
}
package main
import "fmt"

func main() {
	    var c chan int

	   c = make(chan int)
	   limit := 16
	   go func() {
	   	     for i := limit; i > 0; i-- {
	   	     	     fmt.Print(<-c)           produces:
	   	     }                                 0110011101011010
	   }()
	   for i := limit; i > 0; i-- {
	   	     select {
	   	     case c <- 0:
	   	     case c <- 1:
	   	     }
	   }
}
package main
import "fmt"

func main() {
	    var c chan int

	   c = make(chan int)
	   limit := 16
	   go func() {
	   	     for i := limit; i > 0; i-- {
	   	     	     fmt.Print(<-c)           produces:
	   	     }                                 0110011101011010
	   }()
	   for i := limit; i > 0; i-- {
	   	     select {
	   	     case c <- 0:
	   	     case c <- 1:
	   	     }
	   }
}
package main
import "fmt"

func main() {
	    var c chan int

	   c = make(chan int)
	   limit := 16
	   go func() {
	   	     for i := limit; i > 0; i-- {
	   	     	     fmt.Print(<-c)           produces:
	   	     }                                 0110011101011010
	   }()
	   for i := limit; i > 0; i-- {
	   	     select {
	   	     case c <- 0:
	   	     case c <- 1:
	   	     }
	   }
}
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

More Related Content

What's hot

Erlang bootstrap course
Erlang bootstrap courseErlang bootstrap course
Erlang bootstrap courseMartin Logan
 
Advanced Python, Part 1
Advanced Python, Part 1Advanced Python, Part 1
Advanced Python, Part 1Zaar Hai
 
Introduction to Ruby Programming Language
Introduction to Ruby Programming LanguageIntroduction to Ruby Programming Language
Introduction to Ruby Programming LanguageNicolò Calcavecchia
 
Lecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of TwenteLecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of TwenteDirkjan Bussink
 
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM LanguageCodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM LanguageCodeFest
 
Kotlin으로 안드로이드 개발하기
Kotlin으로 안드로이드 개발하기Kotlin으로 안드로이드 개발하기
Kotlin으로 안드로이드 개발하기Taehwan kwon
 
Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Chang W. Doh
 
Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Guillaume Laforge
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecLoïc Descotte
 
Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)Cody Engel
 
Peyton jones-2009-fun with-type_functions-slide
Peyton jones-2009-fun with-type_functions-slidePeyton jones-2009-fun with-type_functions-slide
Peyton jones-2009-fun with-type_functions-slideTakayuki Muranushi
 
Swift for TensorFlow - CoreML Personalization
Swift for TensorFlow - CoreML PersonalizationSwift for TensorFlow - CoreML Personalization
Swift for TensorFlow - CoreML PersonalizationJacopo Mangiavacchi
 
F# delight
F# delightF# delight
F# delightpriort
 

What's hot (20)

Erlang bootstrap course
Erlang bootstrap courseErlang bootstrap course
Erlang bootstrap course
 
Advanced Python, Part 1
Advanced Python, Part 1Advanced Python, Part 1
Advanced Python, Part 1
 
Introduction to Ruby Programming Language
Introduction to Ruby Programming LanguageIntroduction to Ruby Programming Language
Introduction to Ruby Programming Language
 
Lecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of TwenteLecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of Twente
 
ddd+scala
ddd+scaladdd+scala
ddd+scala
 
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM LanguageCodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
Designing Ruby APIs
Designing Ruby APIsDesigning Ruby APIs
Designing Ruby APIs
 
Python Puzzlers
Python PuzzlersPython Puzzlers
Python Puzzlers
 
Kotlin으로 안드로이드 개발하기
Kotlin으로 안드로이드 개발하기Kotlin으로 안드로이드 개발하기
Kotlin으로 안드로이드 개발하기
 
Ruby basics
Ruby basicsRuby basics
Ruby basics
 
Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요
 
Groovy 2.0 webinar
Groovy 2.0 webinarGroovy 2.0 webinar
Groovy 2.0 webinar
 
Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
 
Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)
 
Peyton jones-2009-fun with-type_functions-slide
Peyton jones-2009-fun with-type_functions-slidePeyton jones-2009-fun with-type_functions-slide
Peyton jones-2009-fun with-type_functions-slide
 
Swift for TensorFlow - CoreML Personalization
Swift for TensorFlow - CoreML PersonalizationSwift for TensorFlow - CoreML Personalization
Swift for TensorFlow - CoreML Personalization
 
F# delight
F# delightF# delight
F# delight
 
Groovy closures
Groovy closuresGroovy closures
Groovy closures
 

Similar to Go &lt;-> Ruby

GoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google GoGoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google GoEleanor McHugh
 
Chapter 2 Python Language Basics, IPython.pptx
Chapter 2 Python Language Basics, IPython.pptxChapter 2 Python Language Basics, IPython.pptx
Chapter 2 Python Language Basics, IPython.pptxSovannDoeur
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingMuthu Vinayagam
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoMatt Stine
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsMichael Pirnat
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptxGuy Komari
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonUC San Diego
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard LibrarySantosh Rajan
 
Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05cKaz Yoshikawa
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)Saifur Rahman
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingGarth Gilmour
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUadAccount
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma IntroduçãoÍgor Bonadio
 
Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?Adam Dudczak
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my dayTor Ivry
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayUtkarsh Sengar
 

Similar to Go &lt;-> Ruby (20)

GoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google GoGoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google Go
 
Chapter 2 Python Language Basics, IPython.pptx
Chapter 2 Python Language Basics, IPython.pptxChapter 2 Python Language Basics, IPython.pptx
Chapter 2 Python Language Basics, IPython.pptx
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to Go
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) Things
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python basic
Python basicPython basic
Python basic
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
 
Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05c
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional Programming
 
Python
PythonPython
Python
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptx
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma Introdução
 
Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my day
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 

More from Eleanor McHugh

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdfEleanor McHugh
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsEleanor McHugh
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityEleanor McHugh
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]Eleanor McHugh
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveEleanor McHugh
 
Go for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionGo for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionEleanor McHugh
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]Eleanor McHugh
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with goEleanor McHugh
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored SpacesEleanor McHugh
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignEleanor McHugh
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by designEleanor McHugh
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trustEleanor McHugh
 
Going Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoGoing Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoEleanor McHugh
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleEleanor McHugh
 
Go for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd editionGo for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd editionEleanor McHugh
 
Going Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoGoing Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoEleanor McHugh
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goEleanor McHugh
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountabilityEleanor McHugh
 

More from Eleanor McHugh (20)

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient Collections
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data Integrity
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's Perspective
 
Go for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionGo for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd edition
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with go
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored Spaces
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By Design
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by design
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trust
 
Going Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoGoing Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google Go
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at Scale
 
Hello Go
Hello GoHello Go
Hello Go
 
Go for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd editionGo for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd edition
 
Going Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoGoing Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with Go
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in go
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountability
 

Recently uploaded

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

Go &lt;-> Ruby

  • 1. Go <=> Ruby a selection of odd lightning talks @feyeleanor http://slides.games-with-brains.net/
  • 2. The Wild-Eyed Screamer
  • 9. Hacker 101 this presentation contains code that code is probably broken
  • 10. Hacker 101 this presentation contains code that code is probably broken if this bothers you - fix it
  • 11. Hacker 101 this presentation contains code that code is probably broken if this bothers you - fix it it’s called a learning experience
  • 12. Hacker 101 this presentation contains code that code is probably broken if this bothers you - fix it it’s called a learning experience and will make you a better persontm
  • 13. Google Go it’s not just for Google
  • 16. of very few words
  • 17. who lives at google
  • 18. package main import "fmt" const HELLO string = "hello" var WORLD string = "world" func main() { fmt.Println(HELLO, WORLD) }
  • 19. package main import "fmt" const HELLO string = "hello" var WORLD string = "world" func main() { fmt.Println(HELLO, WORLD) }
  • 20. package main import "fmt" const HELLO string = "hello" var WORLD string = "world" func main() { fmt.Println(HELLO, WORLD) }
  • 21. package main import "fmt" const HELLO string = "hello" var WORLD string = "world" func main() { fmt.Println(HELLO, WORLD) }
  • 22. package organisation import var, const, type declaration func, interface, map, struct, chan if ... else switch ... case ... fallthrough ... default select ... case control flow for for ... range break, continue go, goto, defer, return
  • 23. boolean, numeric, array value structure, interface reference pointer, slice, string, map, channel invocation function, method, closure
  • 24. Go Ruby compilation static AOT runtime mutable memory garbage collected syntax minimalist humanistic strong dynamic type embedding inheritance dispatch procedural invocation message passing semantics statements expressions
  • 25. Ruby typing is tricksy lies we tell ourself about type
  • 26. superclass modules class modules message instance
  • 27. superclass modules class modules type 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 end end class DoubleCounter < Counter def Tick super @count += 1 end end n = new(DoubleCounter) puts n.Tick puts n.superclass.Tick
  • 33. class Counter attr_writer :count def initialize @count = 0 end def Tick @count += 1 end end class DoubleCounter < Counter def Tick super @count += 1 end end n = new(DoubleCounter) puts n.Tick puts n.superclass.Tick
  • 34. class Counter attr_writer :count def initialize @count = 0 end def Tick @count += 1 end end class DoubleCounter < Counter def Tick super @count += 1 end end n = new(DoubleCounter) puts n.Tick puts n.superclass.Tick
  • 35. class Counter attr_writer :count def initialize @count = 0 end def Tick @count += 1 end end class DoubleCounter < Counter def Tick super @count += 1 end end n = new(DoubleCounter) puts n.Tick puts n.superclass.Tick
  • 36. class Counter attr_writer :count def initialize @count = 0 end def Tick @count += 1 end end class DoubleCounter < Counter def Tick super @count += 1 end end n = new(DoubleCounter) puts n.Tick puts n.superclass.Tick
  • 37. class Counter attr_writer :count def initialize @count = 0 end def Tick @count += 1 end end class DoubleCounter < Counter def Tick super @count += 1 end end n = new(DoubleCounter) puts n.Tick puts n.superclass.Tick
  • 38. down a rabbit hole instances are their own classes
  • 39. down a rabbit hole instances are their own classes and all classes are mutable at runtime
  • 40. down a rabbit hole instances are their own classes all classes are mutable at runtime so inheritance pathways can be altered
  • 41. down a rabbit hole instances are their own classes and all classes are mutable at runtime so inheritance pathways can be altered making Ruby very flexible
  • 42. down a rabbit hole instances are their own classes and all classes are mutable at runtime so inheritance pathways can be altered making Ruby very flexible at the cost of type uncertainty
  • 43. down a rabbit hole instances are their own classes and all classes are mutable at runtime so inheritance pathways can be altered making Ruby very flexible at the cost of type uncertainty which really bugs computer scientists
  • 44. type in Go is safetm clearly 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 Integer type Int int func (i *Int) Add(x int) { *i += Int(x) }
  • 50. package Integer type Int int func (i *Int) Add(x int) { *i += Int(x) }
  • 51. package Integer type Int int func (i *Int) Add(x int) { *i += Int(x) }
  • 52. package Integer type Int int func (i *Int) Add(x int) { *i += Int(x) }
  • 53. type Buffer []Int func (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 []Int func (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 []Int func (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 main import "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 main import "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 main import "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 main import "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 main import "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 Vector import . "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 Vector import . "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 Vector import . "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 Vector import . "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 Vector import . "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 int func (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 int func (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 int func (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 []float32 func (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 []float32 func (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 []float32 func (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 hole an object has known static type
  • 83. down a rabbit hole an object has known static type this fixed type is determined at linking
  • 84. down a rabbit hole an object has known static type this fixed type is determined at linking no new types can be created at runtime
  • 85. down a rabbit hole an object has known static type this fixed type is determined at linking no new types can be created at runtime so dynamism is bounded to a fixed set
  • 86. down a rabbit hole an object has known static type this fixed type is determined at linking no new types can be created at runtime so dynamism is bounded to this fixed set and 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 Vector import "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 Vector import "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 Vector import "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 Vector import "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 Vector import "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 Vector import "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 Vector import "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 Vector import "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.inc TARG=integer GOFILES= integer.go vector.go include $(GOROOT)/src/Make.pkg
  • 104. package Vector import "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 Vector import "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 Vector import "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 Vector import "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 Vector import "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 Vector import "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.a 6g -o _gotest_.6 integer.go vector.go nominal_typing_test.go embedded_typing_benchmark_test.go embedded_typing_test.go rm -f _test/scripts.a gopack grc _test/scripts.a _gotest_.6 PASS integer.BenchmarkVectorSwap 200000000 8 ns/op integer.BenchmarkVectorClone6 10000000 300 ns/op
  • 111. $ gotest -bench="Benchmark" rm -f _test/scripts.a 6g -o _gotest_.6 integer.go vector.go nominal_typing_test.go embedded_typing_benchmark_test.go embedded_typing_test.go rm -f _test/scripts.a gopack grc _test/scripts.a _gotest_.6 PASS integer.BenchmarkVectorSwap 200000000 8 ns/op integer.BenchmarkVectorClone6 10000000 300 ns/op
  • 112. $ gotest -bench="Benchmark" rm -f _test/scripts.a 6g -o _gotest_.6 integer.go vector.go nominal_typing_test.go embedded_typing_benchmark_test.go embedded_typing_test.go rm -f _test/scripts.a gopack grc _test/scripts.a _gotest_.6 PASS integer.BenchmarkVectorSwap 200000000 8 ns/op integer.BenchmarkVectorClone6 10000000 300 ns/op
  • 113. $ gotest -bench="Benchmark" rm -f _test/scripts.a 6g -o _gotest_.6 integer.go vector.go nominal_typing_test.go embedded_typing_benchmark_test.go embedded_typing_test.go rm -f _test/scripts.a gopack grc _test/scripts.a _gotest_.6 PASS integer.BenchmarkVectorSwap 200000000 8 ns/op integer.BenchmarkVectorClone6 10000000 300 ns/op
  • 114. $ gotest -bench="Benchmark" rm -f _test/scripts.a 6g -o _gotest_.6 integer.go vector.go nominal_typing_test.go embedded_typing_benchmark_test.go embedded_typing_test.go rm -f _test/scripts.a gopack grc _test/scripts.a _gotest_.6 PASS integer.BenchmarkVectorSwap 200000000 8 ns/op integer.BenchmarkVectorClone6 10000000 300 ns/op
  • 115. exceptional fun because 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 Go dynamism through run-time type manipulation
  • 146. package generalise import "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 generalise import "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 generalise import . "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 generalise import . "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 generalise import . "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 generalise import . "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 generalise import . "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 generalise import . "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 generalise import . "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 generalise import . "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 generalise import . "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 generalise import . "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 generalise import . "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 generalise import . "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 generalise import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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 raw import . "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) }
  • 240. 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) }
  • 241. 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) }
  • 242. go f(){}() / yourself / map/reduce for all the family
  • 243. package main import "fmt" func main() { var c chan int c = make(chan int) limit := 16 go func() { for i := limit; i > 0; i-- { fmt.Print(<-c) produces: } 0110011101011010 }() for i := limit; i > 0; i-- { select { case c <- 0: case c <- 1: } } }
  • 244. package main import "fmt" func main() { var c chan int c = make(chan int) limit := 16 go func() { for i := limit; i > 0; i-- { fmt.Print(<-c) produces: } 0110011101011010 }() for i := limit; i > 0; i-- { select { case c <- 0: case c <- 1: } } }
  • 245. package main import "fmt" func main() { var c chan int c = make(chan int) limit := 16 go func() { for i := limit; i > 0; i-- { fmt.Print(<-c) produces: } 0110011101011010 }() for i := limit; i > 0; i-- { select { case c <- 0: case c <- 1: } } }
  • 246. package main import "fmt" func main() { var c chan int c = make(chan int) limit := 16 go func() { for i := limit; i > 0; i-- { fmt.Print(<-c) produces: } 0110011101011010 }() for i := limit; i > 0; i-- { select { case c <- 0: case c <- 1: } } }

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. \n
  135. \n
  136. \n
  137. \n
  138. \n
  139. \n
  140. \n
  141. \n
  142. \n
  143. \n
  144. \n
  145. \n
  146. \n
  147. \n
  148. \n
  149. \n
  150. \n
  151. \n
  152. \n
  153. \n
  154. \n
  155. \n
  156. \n
  157. \n
  158. \n
  159. \n
  160. \n
  161. \n
  162. \n
  163. \n
  164. \n
  165. \n
  166. \n
  167. \n
  168. \n
  169. \n
  170. \n
  171. \n
  172. \n
  173. \n
  174. \n
  175. \n
  176. \n
  177. \n
  178. \n
  179. \n
  180. \n
  181. \n
  182. \n
  183. \n
  184. \n
  185. \n
  186. \n
  187. \n
  188. \n
  189. \n
  190. \n
  191. \n
  192. \n
  193. \n
  194. \n
  195. \n
  196. \n
  197. \n
  198. \n
  199. \n
  200. \n
  201. \n
  202. \n
  203. \n
  204. \n
  205. \n
  206. \n
  207. \n
  208. \n
  209. \n
  210. \n
  211. \n
  212. \n
  213. \n
  214. \n
  215. \n
  216. \n
  217. \n
  218. \n
  219. \n
  220. \n
  221. \n
  222. \n
  223. \n
  224. \n
  225. \n
  226. \n
  227. \n
  228. \n
  229. \n
  230. \n
  231. \n
  232. \n
  233. \n
  234. \n
  235. \n
  236. \n
  237. \n
  238. \n
  239. \n
  240. \n
  241. \n
  242. \n
  243. \n
  244. \n
  245. \n
  246. \n
  247. \n
  248. \n
  249. \n
  250. \n
  251. \n
  252. \n
  253. \n
  254. \n
  255. \n
  256. \n
  257. \n
  258. \n
  259. \n
  260. \n
  261. \n
  262. \n
  263. \n
  264. \n
  265. \n
  266. \n
  267. \n
  268. \n
  269. \n
  270. \n
  271. \n
  272. \n
  273. \n
  274. \n
  275. \n
  276. \n
  277. \n
  278. \n
  279. \n
  280. \n
  281. \n
  282. \n
  283. \n
  284. \n
  285. \n
  286. \n
  287. \n
  288. \n
  289. \n
  290. \n
  291. \n
  292. \n
  293. \n
  294. \n
  295. \n
  296. \n
  297. \n
  298. \n
  299. \n
  300. \n
  301. \n
  302. \n
  303. \n
  304. \n
  305. \n
  306. \n
  307. \n
  308. \n
  309. \n
  310. \n
  311. \n
  312. \n
  313. \n
  314. \n
  315. \n
  316. \n
  317. \n
  318. \n
  319. \n
  320. \n
  321. \n
  322. \n
  323. \n
  324. \n
  325. \n
  326. \n
  327. \n
  328. \n
  329. \n
  330. \n
  331. \n
  332. \n
  333. \n
  334. \n
  335. \n
  336. \n
  337. \n
  338. \n
  339. \n
  340. \n
  341. \n
  342. \n
  343. \n
  344. \n
  345. \n
  346. \n
  347. \n
  348. \n
  349. \n
  350. \n
  351. \n
  352. \n
  353. \n
  354. \n
  355. \n
  356. \n
  357. \n
  358. \n
  359. \n
  360. \n
  361. \n
  362. \n
  363. \n
  364. \n
  365. \n
  366. \n
  367. \n
  368. \n
  369. \n
  370. \n
  371. \n
  372. \n
  373. \n
  374. \n
  375. \n
  376. \n
  377. \n
  378. \n
  379. \n
  380. \n
  381. \n
  382. \n
  383. \n
  384. \n
  385. \n
  386. \n
  387. \n
  388. \n
  389. \n
  390. \n
  391. \n
  392. \n
  393. \n
  394. \n
  395. \n
  396. \n
  397. \n
  398. \n
  399. \n
  400. \n
  401. \n
  402. \n
  403. \n
  404. \n
  405. \n
  406. \n
  407. \n
  408. \n