File: const.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 (154 lines) | stat: -rw-r--r-- 3,523 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
This test checks hovering over constants.

-- go.mod --
module mod.com

go 1.17

-- c.go --
package c

import (
	"math"
	"time"
)

const X = 0 //@hover("X", "X", bX)

// dur is a constant of type time.Duration.
const dur = 15*time.Minute + 10*time.Second + 350*time.Millisecond //@hover("dur", "dur", dur)

// MaxFloat32 is used in another package.
const MaxFloat32 = 0x1p127 * (1 + (1 - 0x1p-23))

// Numbers.
func _() {
	const hex, bin = 0xe34e, 0b1001001

	const (
		// no inline comment
		decimal = 153

		numberWithUnderscore int64 = 10_000_000_000
		octal                      = 0o777
		expr                       = 2 << (0b111&0b101 - 2)
		boolean                    = (55 - 3) == (26 * 2)
	)

	_ = decimal              //@hover("decimal", "decimal", decimalConst)
	_ = hex                  //@hover("hex", "hex", hexConst)
	_ = bin                  //@hover("bin", "bin", binConst)
	_ = numberWithUnderscore //@hover("numberWithUnderscore", "numberWithUnderscore", numberWithUnderscoreConst)
	_ = octal                //@hover("octal", "octal", octalConst)
	_ = expr                 //@hover("expr", "expr", exprConst)
	_ = boolean              //@hover("boolean", "boolean", boolConst)

	const ln10 = 2.30258509299404568401799145468436420760110148862877297603332790

	_ = ln10 //@hover("ln10", "ln10", ln10Const)
}

// Iota.
func _() {
	const (
		a = 1 << iota
		b
	)

	_ = a //@hover("a", "a", aIota)
	_ = b //@hover("b", "b", bIota)
}

// Strings.
func _() {
	const (
		str     = "hello" + " " + "world"
		longStr = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eget ipsum non nunc
molestie mattis id quis augue. Mauris dictum tincidunt ipsum, in auctor arcu congue eu.
Morbi hendrerit fringilla libero commodo varius. Vestibulum in enim rutrum, rutrum tellus
aliquet, luctus enim. Nunc sem ex, consectetur id porta nec, placerat vel urna.`
	)

	_ = str     //@hover("str", "str", strConst)
	_ = longStr //@hover("longStr", "longStr", longStrConst)
}

// Constants from other packages.
func _() {
	_ = math.Log2E //@hover("Log2E", "Log2E", log2eConst)
}

-- @bX --
```go
const X untyped int = 0
```

@hover("X", "X", bX)


[`c.X` on pkg.go.dev](https://pkg.go.dev/mod.com#X)
-- @dur --
```go
const dur time.Duration = 15*time.Minute + 10*time.Second + 350*time.Millisecond // 15m10.35s
```

dur is a constant of type time.Duration.
-- @decimalConst --
```go
const decimal untyped int = 153
```

no inline comment
-- @hexConst --
```go
const hex untyped int = 0xe34e // 58190
```
-- @binConst --
```go
const bin untyped int = 0b1001001 // 73
```
-- @numberWithUnderscoreConst --
```go
const numberWithUnderscore int64 = 10_000_000_000 // 10000000000
```
-- @octalConst --
```go
const octal untyped int = 0o777 // 511
```
-- @exprConst --
```go
const expr untyped int = 2 << (0b111&0b101 - 2) // 16
```
-- @boolConst --
```go
const boolean untyped bool = (55 - 3) == (26 * 2) // true
```
-- @ln10Const --
```go
const ln10 untyped float = 2.30258509299404568401799145468436420760110148862877297603332790 // 2.30259
```
-- @aIota --
```go
const a untyped int = 1 << iota // 1
```
-- @bIota --
```go
const b untyped int = 2
```
-- @strConst --
```go
const str untyped string = "hello world"
```
-- @longStrConst --
```go
const longStr untyped string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur e...
```
-- @log2eConst --
```go
const math.Log2E untyped float = 1 / Ln2 // 1.4427
```

Mathematical constants.


[`math.Log2E` on pkg.go.dev](https://pkg.go.dev/math#Log2E)