go-engine 0.1.5

The wrapper of the Goscript project.
Documentation
package main

import "fmt2"

type geometry interface {
    area() float64
    perim() float64
}

type rect struct {
    width, height float64
}

func (r rect) perim() float64 {
    return 2*r.width + 2*r.height
}

func (r rect) area() float64 {
    return r.width * r.height
}

func test1() {

    a := geometry(nil)
    var b geometry = (geometry)(nil)
    assert(a == nil)
    assert(b == nil)

    var r *rect
    b = r
    assert(b != nil)
}


////////////////////////////////////

type I interface {
	printVal()
}

type S struct {
	i int
}

func (s S) printVal() {
    assert(s.i == 0)
	fmt2.Println(s.i)
}

func test2() {
	var i I

	var s S
	i = s
	s.i = 9
	i.printVal()
}


func main() {
    test1()
    test2()
}