golang import前加两个斜杠是啥意思?

package main


import (
// "lib/redis"
)


请问下//代表的啥含义?

已邀请:

lifei6671 - PHPer

赞同来自: gaoxu387

注释。。

niugou - 宁可十年不将军,不可一日不拱卒。

赞同来自:

这个不是单行注释吗?不知道还有什么特别的。

stirlingx - https://github.com/liyue201

赞同来自:

呵呵的意思

thomas_y

赞同来自:

牛啊,哥们

gaoxu387

赞同来自:

哈哈,我周五脑子估计短路了。。这帖子结了

james4e

赞同来自:

https://golang.org/pkg/cmd/go/#hdr-Import_path_checking


A package statement is said to have an “import comment” if it is immediately followed (before the next newline) by a comment of one of these two forms:


// import "path"
/ import "path" /


The go command will refuse to install a package with an import comment under any import path except the one named in the comment.


Continuing the example, as long as one file from package pdf contains


package pdf // import "rsc.io/pdf"

the go command will reject "go get github.com/rsc/pdf", ensuring that the code can be moved without breaking users.

要回复问题请先登录注册