blob: 68546b0017a5cfe01c816cb04328aa0986213dd8 [file] [log] [blame]
This test executes definition requests over doc links.
-- go.mod --
module mod.com
go 1.19
-- path/path.go --
package path
func Join() //@loc(Join, "Join")
-- a.go --
package p
import "strconv" //@loc(strconv, `"strconv"`)
import pathpkg "mod.com/path"
import _ "unsafe"
const NumberBase = 10 //@loc(NumberBase, "NumberBase")
// [Conv] converts s to an int. //@def("Conv", Conv)
func Conv(s string) int { //@loc(Conv, "Conv")
// [strconv.ParseInt] parses s and returns the integer corresponding to it. //@def("strconv", strconv)
// [NumberBase] is the base to use for number parsing. //@def("NumberBase", NumberBase)
i, _ := strconv.ParseInt(s, NumberBase, 64)
return int(i)
}
type T struct {
Field int //@ loc(Field, "Field")
}
func (T) Method() {} //@ loc(Method, "Method")
// The declared and imported names of the package both work:
// [path.Join] //@ def("Join", Join)
// [pathpkg.Join] //@ def("Join", Join)
//
// Also, both [T.Field] and //@ def("Field", Field)
// [T.Method] are supported. //@ def("Method", Method)
func _() {
pathpkg.Join()
}
// Built-in and unsafe symbols work too.
// [unsafe.Pointer] //@def("Pointer", UNSAFE)
// [unsafe.Slice] //@def("Slice", UNSAFE)
// [int] //@def("int", BUILTIN)
// [error] //@def("error", BUILTIN)
// [error.Error] //@def("Error", BUILTIN)
func _()