码迷,mamicode.com
首页 > 其他好文 > 详细

my first go

时间:2014-05-16 22:09:34      阅读:431      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   c   java   

bubuko.com,布布扣
/**
 * Created with IntelliJ IDEA.
 * User: li_zhe
 * Date: 14/05/06
 * Time: 12:34
 * To change this template use File | Settings | File Templates.
 */
package main

//实现格式化的I/O
import "fmt"

func main() {

    //var a int
    //var b bool

    //a = 15
    //b = false

    a := 15
    b :=false

    fmt.Println(a)
    fmt.Println(b)

    //var (
        //a int
        //b bool
    //)

    c,d := 12,15
    fmt.Println(c)
    fmt.Println(d)

    //任何赋给‘_‘的值都会被丢弃
    _,e := 20,21
    fmt.Println(e)

    fmt.Printf("Hello world!")

    const (
        l = iota
        j = iota
    )
    fmt.Println(l)
    fmt.Println(j)

    var s string = "HELLO"
    by := []byte(s)
    by[0] = ‘c‘

    s2 := string(by)
    fmt.Printf("%s\n" , s2)



}
bubuko.com,布布扣

 

bubuko.com,布布扣
/**
 * Created with IntelliJ IDEA.
 * User: li_zhe
 * Date: 14/05/13
 * Time: 11:25
 * To change this template use File | Settings | File Templates.
 */
package main

import "fmt"

func main() {

    s := "HELLO " + "WORLD"
    fmt.Printf(s+"\n")

    var c complex64 = 5+5i
    fmt.Printf("Value is: %v",c)
    fmt.Printf("\n")

    list := []string{"a","b","c","d","e"}

    for k,v := range list {

        fmt.Println(k)
        fmt.Printf(v+"\n");
    }

    for pos,char := range "Process" {
        fmt.Printf("Charactor ‘%c‘ starts at byte position %d\n",char,pos)
    }

    for i := 0 ;i < 10 ;i++ {

        if i > 5 {
            continue
        }
        fmt.Println(i)
    }

    fmt.Println("===============================")

    K: for i := 0;i < 10; i++ {
           for j := 0;j < 10; j++ {

               if j > 5 {
                   break K
               }
               fmt.Println(j)
           }
    }

    i := 0
    switch i {

        case 0:fallthrough
        case 1:
             fmt.Printf("is 1!")
        default:
            fmt.Printf("is default!")
    }

    switch i {

    case 0,1,2,3:
        fmt.Printf("true!")
    case 5:
        fmt.Printf("is 1!")
    default:
        fmt.Printf("is default!")
    }
}
bubuko.com,布布扣

 

my first go,布布扣,bubuko.com

my first go

标签:style   blog   class   code   c   java   

原文地址:http://www.cnblogs.com/harryV/p/3725083.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!