测试代码
package test
import "testing"
func TestFirstTry(t *testing.T) {
t.Log("My first try!")
}
变量赋值(一个语句中对多个变量赋值)
package fib
import (
"testing"
)
func TestFibList(t *testing.T){
var numa int = 1
var numb int = 1
var(
numa int = 1
numb = 1
)
numa := 1
numb := 1
const (
Monday = iota +1
Tuerday
Wednesday
Thursday
Friday
Saturday
Sunday
)
const(
Opn = 1 << iota
Close
Pending
)
for i:=0;i<5;i++{
t.Log(" ",numb)
tmp:= numa
numa = numb
numb = tmp+numa
}
t.Log()
}
func TestExchange(t *testing.T){
numa := 1
numb := 2
numa,numb = numb,numa
t.Log(numa,numb)
}
Go常量测试代码
package constant_test
import "testing"
const(
Monday = iota + 1
Tuesday
Wednesday
Tursday
Friday
Saturday
Sunday
)
const(
Readable = 1 << iota
Writeable
Executable
)
func TestConstantTry(t *testing.T){
t.Log(Monday,Tuesday)
}
func TestConstantTry1(t *testing.T){
a:= 7
t.Log(a&Readable,a&Writeable,a&Executable)
}