Created
September 14, 2012 01:30
-
-
Save itang/3719264 to your computer and use it in GitHub Desktop.
type go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Integer int | |
type Name string | |
func main() { | |
// undertaking type can assign to Typed var, 同 undertaking type -> Typed var | |
var i Integer = 1 | |
fmt.Println(i) | |
// Typed var -> undertaking type, 强制类型转换 | |
var i1 int = int(i) | |
fmt.Println(i1) | |
// undertaking type -> Typed var , 强制类型转换 | |
var i2 Integer = Integer(100) | |
fmt.Println(i2) | |
var name1 Name = "itang" | |
fmt.Println(name1) | |
var name2 string = string(name1) | |
fmt.Println(name2) | |
var name3 Name = Name("itang") | |
//var name4 string = name3.(string) | |
//fmt.Println(name4) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment