GoPLS Viewer

Home|gopls/go/analysis/passes/stringintconv/testdata/src/a/a.go
1// Copyright 2020 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// This file contains tests for the stringintconv checker.
6
7package a
8
9type A string
10
11type B = string
12
13type C int
14
15type D = uintptr
16
17func StringTest() {
18    var (
19        i int
20        j rune
21        k byte
22        l C
23        m D
24        n = []int{012}
25        o struct{ x int }
26    )
27    const p = 0
28    _ = string(i// want `^conversion from int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$`
29    _ = string(j)
30    _ = string(k)
31    _ = string(p)    // want `^conversion from untyped int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$`
32    _ = A(l)         // want `^conversion from C \(int\) to A \(string\) yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$`
33    _ = B(m)         // want `^conversion from uintptr to B \(string\) yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$`
34    _ = string(n[1]) // want `^conversion from int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$`
35    _ = string(o.x)  // want `^conversion from int to string yields a string of one rune, not a string of digits \(did you mean fmt\.Sprint\(x\)\?\)$`
36}
37
MembersX
StringTest.j
StringTest.k
StringTest.p
A
C
StringTest
StringTest.l
StringTest.m
B
D
StringTest.i
Members
X