File: comment.txt

package info (click to toggle)
golang-golang-x-tools 1%3A0.25.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 22,724 kB
  • sloc: javascript: 2,027; asm: 1,645; sh: 166; yacc: 155; makefile: 49; ansic: 8
file content (82 lines) | stat: -rw-r--r-- 2,125 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
This test checks hovering over doc links in comments.

Requires go1.20+ for the unsafe package test.

-- flags --
-min_go=go1.20

-- go.mod --
module mod.com

go 1.20

-- a.go --
package p

import (
	"unsafe"

	"mod.com/util" //@hover(`"mod.com/util"`, `"mod.com/util"`, strconv)
)

// [NumberBase] is the base to use for number parsing. //@hover("NumberBase", "NumberBase", NumberBase)
const NumberBase = 10

// [Conv] converts s to an int. //@hover("Conv", "Conv", Conv)
func Conv(s string) int {
	// [util.ParseInt] parses s and returns the integer corresponding to it. //@hover("util", "util", util),hover("ParseInt", "ParseInt", strconvParseInt)
	// [NumberBase] is the base to use for number parsing.
	i, _ := util.ParseInt(s, NumberBase, 64)
	return int(i)
}

// unsafeConv converts s to a byte slice using [unsafe.Pointer]. hover("Pointer", "Pointer", unsafePointer)
func unsafeConv(s string) []byte {
	p := unsafe.StringData(s)
	b := unsafe.Slice(p, len(s))
	return b
}

-- util/conv.go --
// Package util provides utility functions.
package util

import "strconv"

// ParseInt interprets a string s in the given base (0, 2 to 36) and
// bit size (0 to 64) and returns the corresponding value i.
func ParseInt(s string, base int, bitSize int) (int64, error) {
	return strconv.ParseInt(s, base, bitSize)
}

-- @Conv --
```go
func Conv(s string) int
```

\[Conv] converts s to an int. //@hover("Conv", "Conv", Conv)


[`p.Conv` on pkg.go.dev](https://pkg.go.dev/mod.com#Conv)
-- @NumberBase --
```go
const NumberBase untyped int = 10
```

\[NumberBase] is the base to use for number parsing. //@hover("NumberBase", "NumberBase", NumberBase)


[`p.NumberBase` on pkg.go.dev](https://pkg.go.dev/mod.com#NumberBase)
-- @strconv --
Package util provides utility functions.
-- @strconvParseInt --
```go
func ParseInt(s string, base int, bitSize int) (int64, error)
```

ParseInt interprets a string s in the given base (0, 2 to 36) and bit size (0 to 64) and returns the corresponding value i.


[`util.ParseInt` on pkg.go.dev](https://pkg.go.dev/mod.com/util#ParseInt)
-- @util --
Package util provides utility functions.