go/doc/comment: 结构体字段文档的doc链接无法工作

tyg4sfes  于 5个月前  发布在  Go
关注(0)|答案(6)|浏览(58)

你使用的Go版本是什么( go version )?

$ go version
go version go1.19.1 darwin/amd64

这个问题在最新版本中是否会重现?

是的

你正在使用什么操作系统和处理器架构( go env )?

go env 输出

$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/Will/Library/Caches/go-build"
GOENV="/Users/Will/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/Will/Developer/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/Will/Developer/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.19.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.19.1/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/Will/Developer/ebnf/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bx/qk0phsxd265fqj512dnnpg080000gn/T/go-build1943356326=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.19.1 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.19.1
uname -v: Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64
ProductName:	macOS
ProductVersion:	12.6
BuildVersion:	21G115
lldb --version: lldb-1400.0.30.3
Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)

你做了什么?

// FirstFollowConflictError is a first/follow LL(1) grammar parse conflict.
type FirstFollowConflictError struct {
	Nonterminal string
	// An [Identifier] or [Literal]
	Terminal any // an [Identifier] or [Literal]
}
$ go doc FirstFollowConflictError

你期望看到什么?

package ebnf // import "."

type FirstFollowConflictError struct {
	Nonterminal string
	// An Identifier or Literal
	Terminal any // an Identifier or Literal
}
    FirstFollowConflictError is a first/follow LL(1) grammar parse conflict.

你实际看到了什么?

package ebnf // import "."

type FirstFollowConflictError struct {
	Nonterminal string
	// An [Identifier] or [Literal]
	Terminal any // an [Identifier] or [Literal]
}
    FirstFollowConflictError is a first/follow LL(1) grammar parse conflict.

注意上面和旁边的Terminal字段周围的方括号。它们没有被解析和呈现为文档链接。如果将它们放在类型声明上方,括号就会消失,如预期的那样。

xkftehaa

xkftehaa1#

IdentifierLiteral 是什么?

0ve6wy6x

0ve6wy6x2#

包范围内的结构体类型。

package ebnf // import "."

type Identifier struct {
	Text string
}

type Literal struct {
	Text string
}
nbnkbykc

nbnkbykc3#

请查看https://pkg.go.dev/github.com/willfaught/ebnf@v0.4.1#FirstFollowConflictError以获取完整上下文,尽管那里省略了括号,因为它不起作用。

ckx4rj1h

ckx4rj1h6#

经历类似的事情,有人可以看一下#67473

相关问题