This file is indexed.

/usr/share/gocode/src/github.com/tent/canonical-json-go/encode_test.go is in golang-github-tent-canonical-json-go-dev 0.0~git20130607.0.96e4ba3-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
package cjson

import (
	"testing"
)

type marshaling struct{}

func (m marshaling) MarshalJSON() ([]byte, error) { return []byte("\t\n  {\"b\":234,\"a\":123}"), nil }

func TestCanonicalization(t *testing.T) {
	input := struct {
		C map[string]interface{} `json:"c"`
		A string                 `json:"a"`
		D []int                  `json:"d"`
		B int                    `json:"b"`
		E *marshaling            `json:"e"`
	}{map[string]interface{}{"b": "b", "a": "\n\r", "c": "\"\\<>"}, "a", []int{1, 2, 3}, 1, &marshaling{}}
	expected := `{"a":"a","b":1,"c":{"a":"` + "\n\r" + `","b":"b","c":"\"\\<>"},"d":[1,2,3],"e":{"a":123,"b":234}}`

	output, err := Marshal(input)
	if err != nil {
		t.Errorf("got err = %v, want nil", err)
	}
	if expected != string(output) {
		t.Errorf("got %s, want %s", string(output), expected)
	}
}

func TestFloatError(t *testing.T) {
	input := struct{ A float64 }{1.1}

	_, err := Marshal(input)
	if err == nil {
		t.Errorf("want float error, got nil")
	}
}