golang数组用法

楚天乐 137 0 条
package main

import (
    "fmt"
)

var (
    duration int = 2
)

func main() {
    fmt.Println("test case 1:")
    strs := make([]string, 10)
    strs = append(strs, "1")
    strs = append(strs, "2")
    strs = append(strs, "3")
    for _, val := range strs{
        fmt.Println(val)
    }

    fmt.Println("test case 2:")
    var strs2 []string
    strs2 = append(strs2, "1")
    strs2 = append(strs2, "2")
    strs2 = append(strs2, "3")
    for _, val2 := range strs2{
        fmt.Println(val2)
    }
}

输出

test case 1:

1
2
3
test case 2:
1
2
3

打赏

微信打赏

支付宝打赏



与本文相关的文章

发表我的评论
昵称 (必填)
邮箱 (必填)
网址