This file is indexed.

/usr/share/gocode/src/gopkg.in/gcfg.v1/types/int_test.go is in golang-gopkg-gcfg.v1-dev 0.0~git20150907.0.0ef1a85-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
package types

import (
	"reflect"
	"testing"
)

func elem(p interface{}) interface{} {
	return reflect.ValueOf(p).Elem().Interface()
}

func TestParseInt(t *testing.T) {
	for _, tt := range []struct {
		val  string
		mode IntMode
		exp  interface{}
		ok   bool
	}{
		{"0", Dec, int(0), true},
		{"10", Dec, int(10), true},
		{"-10", Dec, int(-10), true},
		{"x", Dec, int(0), false},
		{"0xa", Hex, int(0xa), true},
		{"a", Hex, int(0xa), true},
		{"10", Hex, int(0x10), true},
		{"-0xa", Hex, int(-0xa), true},
		{"0x", Hex, int(0x0), true},  // Scanf doesn't require digit behind 0x
		{"-0x", Hex, int(0x0), true}, // Scanf doesn't require digit behind 0x
		{"-a", Hex, int(-0xa), true},
		{"-10", Hex, int(-0x10), true},
		{"x", Hex, int(0), false},
		{"10", Oct, int(010), true},
		{"010", Oct, int(010), true},
		{"-10", Oct, int(-010), true},
		{"-010", Oct, int(-010), true},
		{"10", Dec | Hex, int(10), true},
		{"010", Dec | Hex, int(10), true},
		{"0x10", Dec | Hex, int(0x10), true},
		{"10", Dec | Oct, int(10), true},
		{"010", Dec | Oct, int(010), true},
		{"0x10", Dec | Oct, int(0), false},
		{"10", Hex | Oct, int(0), false}, // need prefix to distinguish Hex/Oct
		{"010", Hex | Oct, int(010), true},
		{"0x10", Hex | Oct, int(0x10), true},
		{"10", Dec | Hex | Oct, int(10), true},
		{"010", Dec | Hex | Oct, int(010), true},
		{"0x10", Dec | Hex | Oct, int(0x10), true},
	} {
		typ := reflect.TypeOf(tt.exp)
		res := reflect.New(typ).Interface()
		err := ParseInt(res, tt.val, tt.mode)
		switch {
		case tt.ok && err != nil:
			t.Errorf("ParseInt(%v, %#v, %v): fail; got error %v, want ok",
				typ, tt.val, tt.mode, err)
		case !tt.ok && err == nil:
			t.Errorf("ParseInt(%v, %#v, %v): fail; got %v, want error",
				typ, tt.val, tt.mode, elem(res))
		case tt.ok && !reflect.DeepEqual(elem(res), tt.exp):
			t.Errorf("ParseInt(%v, %#v, %v): fail; got %v, want %v",
				typ, tt.val, tt.mode, elem(res), tt.exp)
		default:
			t.Logf("ParseInt(%v, %#v, %s): pass; got %v, error %v",
				typ, tt.val, tt.mode, elem(res), err)
		}
	}
}