sublime配置
https://github.com/golang/sublime-build/blob/master/docs/configuration.md
我的配置如下。
{ "PATH": "C:\Go\bin", "GOPATH": "E:\Work\Go" }
如下:
Global Sublime Text Settings
To set variables for use in Sublime Text windows, you will want to edit your golang.sublime-settings file. This can be accessed via the menu:
Preferences
Package Settings
Golang Config
Settings – User
Settings are placed in a json structure. Common settings include:
PATH – a string containing a list of directories to search for executables within. On Windows these are separated by ;. OS X and Linux use : as a directory separator.
GOPATH – a string containing one or more Go workspace paths. Like PATH, on Windows multiple paths are separated by ;, on OS X and Linux they are separated by :.
Other Go environment variables will be used if set. Examples include: GOOS, GOARCH, GOROOT and GORACE. The go command documentation has a complete list.
{
“PATH”: “/Users/jsmith/go/bin”,
“GOPATH”: “/Users/jsmith/go”
}
OS-Specific Settings
For users that are working on different operating systems, it may be necessary to segement settings per OS. All settings may be nested under a key of one of the following strings:
“osx”
“windows”
“linux”
{
“osx”: {
“PATH”: “/Users/jsmith/go/bin”,
“GOPATH”: “/Users/jsmith/go”
},
“windows”: {
“PATH”: “C:\Users\jsmith\go\bin”,
“GOPATH”: “C:\Users\jsmith\go”
},
“linux”: {
“PATH”: “/home/jsmith/go/bin”,
“GOPATH”: “/home/jsmith/go”
},
}
Project-Specific Settings
When working on Go projects that use different environments, it may be necessary to define settings in a Sublime Text project file. The Project menu in Sublime Text provides the interface to create and edit project files.
Within projects, all Go settings are placed under the “settings” key and then further under a subkey named “golang”.
{
“folders”: {
“/Users/jsmith/projects/myproj”
},
“settings”: {
“golang”: {
“PATH”: “/Users/jsmith/projects/myproj/env/bin”,
“GOPATH”: “/Users/jsmith/projects/myproj/env”
}
}
}
Project-specific settings may also utilize the OS-specific settings feature.
{
“folders”: {
“/Users/jsmith/projects/myproj”
},
“settings”: {
“golang”: {
“osx”: {
“PATH”: “/Users/jsmith/projects/myproj/env/bin”,
“GOPATH”: “/Users/jsmith/projects/myproj/env”
},
“linux”: {
“PATH”: “/home/jsmith/projects/myproj/env/bin”,
“GOPATH”: “/home/jsmith/projects/myproj/env”
}
}
}
}
相信你已经看懂了。
任何Go语言源码文件都由若干个程序实体组成的。在Go语言中,变量、常量、函数、结构体和接口被统称为“程序实体”,而它们的名字被统称为“标识符”。
标识符可以是任何Unicode编码可以表示的字母字符、数字以及下划线“_”。不过,首字母不能是数字或下划线。
注意:在Go语言中,我们对程序实体的访问权限控制只能通过它们的名字来实现。名字首字母为大写的程序实体可以被任何代码包中的代码访问到。而名字首字母为小写的程序实体则只能被同一个代码包中的代码所访问。
Go语言还规定了一些特定的字符序列。它们被称为“关键字”。编程人员不能把关键字作为标识符。Go语言的关键字如下表:
第一个程序如下:
package main // 代码包声明语句。 // 代码包导入语句。 import ( "fmt" // 导入代码包fmt。 ) // main函数。 func main() { // 打印函数调用语句。用于打印输出信息。 fmt.Println("Go语言编程实战") }
我们在这里需要优先说明的是用于声明变量的关键字var
,以及用于声明常量的关键字const
。要知道,绝大多数的数据类型的值都可以被赋给一个变量,包括函数。而常量则不同,它只能被赋予基本数据类型的值本身。
变量和常量在声明方式方面也有所不同。我们可以在声明一个变量的时候直接为它赋值,也可以只声明不赋值。变量的声明并赋值方式如下:
// 注释:普通赋值,由关键字var、变量名称、变量类型、特殊标记=,以及相应的值组成。 // 若只声明不赋值,则去除最后两个组成部分即可。
var num1 int = 1
或:
var num2, num3 int = 2, 3 // 注释:平行赋值
或:
var ( // 注释:多行赋值 num4 int = 4 num5 int = 5 )
上述这三种变量声明的方式,也适用于常量。但是要注意,对于常量不能出现只声明不赋值的情况。
先记录到这里。睡觉了、