File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 166
166
"env": { "GOPATH": "$HOME/golang:$GS_GOPATH" }
167
167
}
168
168
169
- ` $GS_GOPATH ` 是 gosublime 的伪环境变量, 它自动寻找 ` .go ` 文件所在的 ` ~/go/src ` 来推测 ` ~/go/ ` 为项目位置, 从而自动适应 ` GOPATH ` 。
169
+ ` $GS_GOPATH ` 是 gosublime 的伪环境变量, 它自动寻找 ` .go ` 文件所在的 ` ~/go/src ` 来推测 ` ~/go/ ` 为项目位置, 从而自动适应 ` GOPATH ` 。在这里你应当将$HOME/golang换成你自己的go目录路径。(注意:使用这种方式会在sublime内覆盖原有的GOPATH,如果这里设置出错,会产生GOPATH相关的问题)
170
170
171
171
另外一种为保存sublime 项目 , 修改 project_name.sublime-project 添加节点
172
172
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ Go 常量和一般程序语言不同的是,可以指定相当多的小数位
103
103
104
104
> 需要注意的一点是,这些类型的变量之间不允许互相赋值或操作,不然会在编译时引起编译器报错。
105
105
>
106
- > 如下的代码会产生错误
106
+ > 如下的代码会产生错误:invalid operation: a + b (mismatched types int8 and int32)
107
107
>
108
108
>> var a int8
109
109
@@ -135,7 +135,7 @@ Go 常量和一般程序语言不同的是,可以指定相当多的小数位
135
135
frenchHello = "Bonjour" // 常规赋值
136
136
}
137
137
138
- 在Go中字符串是不可变的,例如下面的代码编译时会报错:
138
+ 在Go中字符串是不可变的,例如下面的代码编译时会报错:cannot assign to s [ 0 ]
139
139
140
140
var s string = "hello"
141
141
s[0] = 'c'
@@ -168,7 +168,10 @@ Go中可以使用`+`操作符来连接两个字符串:
168
168
m := `hello
169
169
world`
170
170
171
- `` ` `` 括起的字符串为Raw字符串,即字符串在代码中的形式就是打印时的形式,它没有字符转义,换行也将原样输出。
171
+ `` ` `` 括起的字符串为Raw字符串,即字符串在代码中的形式就是打印时的形式,它没有字符转义,换行也将原样输出。例如本例中会输出:
172
+
173
+ hello
174
+ world
172
175
173
176
### 错误类型
174
177
Go内置有一个` error ` 类型,专门用来处理错误信息,Go的` package ` 里面还专门有一个包` errors ` 来处理错误:
You can’t perform that action at this time.
0 commit comments