小编lia*_*ggo的帖子

在Go中读取非UTF-8文本文件

我需要读取以GBK编码的文本文件.Go编程语言中的标准库假定所有文本都以UTF-8编码.

如何读取其他编码中的文件?

character-encoding go

22
推荐指数
2
解决办法
9924
查看次数

在Go中,哪种价值反映出来.接口?

j:=1
Run Code Online (Sandbox Code Playgroud)

Kindj就是reflect.Int,符合市场预期.

var j interface{} = 1
Run Code Online (Sandbox Code Playgroud)

Kindj也是reflect.Int.

哪种价值是reflect.Interface什么?

reflection go

13
推荐指数
4
解决办法
2251
查看次数

为什么“进行构建”找不到软件包?

我安装了一个test0软件包$gopath\pkg\windows_386\hello\test0.a,但是当我构建一个依赖于该test0软件包的主软件包时,编译器会说:import "hello/test0": cannot find package

为什么会这样?

我有两个文件:

$gopath/src/hello.go

package main

import (
    "fmt"
    "hello/test0"
)

func main() {
    fmt.Println(test0.Number)
}
Run Code Online (Sandbox Code Playgroud)

$gopath/src/hello/test0/test0.go

package test0

const (
    Number int = 255
)
Run Code Online (Sandbox Code Playgroud)

首先,我运行go install hello/test0,它生成了$gopath\pkg\windows_386\hello\test0.a

然后,我删除目录 $gopath/src/hello

终于,我运行了go build hello.go,编译器说hello.go:5:2: import "hello/test0": cannot find package

package go

5
推荐指数
1
解决办法
8463
查看次数

如何理解两个命名类型在golang中是相同的

类型标识规则指出:

Two named types are identical if their type names originate in the same TypeSpec

我不太明白两个类型名称是如何来自同一个TypeSpec的.你能解释一下或给我看一个例子吗?

types go

4
推荐指数
1
解决办法
269
查看次数

标签 统计

go ×4

character-encoding ×1

package ×1

reflection ×1

types ×1