jemygraw

回复了 jikai507 创建的主题: 请问Golang中如何定义常量数组

这个时候,获取你需要的是这样的代码:

package main

import (
    "fmt"
)

func main() {
    var list = []string{"str1", "str2", "str3", "str4"}
    fmt.Println(list)
}

回复了 inmath 创建的主题: fmt.Println与println有什么区别

func println(args ...Type) The println built-in function formats its arguments in an implementation- specific way and writes the result to standard error. Spaces are always added between arguments and a newline is appended. Println is useful for bootstrapping and debugging; it is not guaranteed to stay in the language.

func Println(a ...interface{}) (n int, err error) Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

区别在于一个输出到stderr,另一个是stdout,一个有返回值,另外一个没有。一个用fmt包支持,另外一个可能将来就没有了。