This file is indexed.

/usr/share/gocode/src/github.com/emicklei/go-restful/examples/restful-route_test.go is in golang-github-emicklei-go-restful-dev 1.2-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
package main

import (
	"net/http"
	"net/http/httptest"
	"strings"
	"testing"

	"github.com/emicklei/go-restful"
)

var (
	Result string
)

func TestRouteExtractParameter(t *testing.T) {
	// setup service
	ws := new(restful.WebService)
	ws.Consumes(restful.MIME_XML)
	ws.Route(ws.GET("/test/{param}").To(DummyHandler))
	restful.Add(ws)

	// setup request + writer
	bodyReader := strings.NewReader("<Sample><Value>42</Value></Sample>")
	httpRequest, _ := http.NewRequest("GET", "/test/THIS", bodyReader)
	httpRequest.Header.Set("Content-Type", restful.MIME_XML)
	httpWriter := httptest.NewRecorder()

	// run
	restful.DefaultContainer.ServeHTTP(httpWriter, httpRequest)

	if Result != "THIS" {
		t.Fatalf("Result is actually: %s", Result)
	}
}

func DummyHandler(rq *restful.Request, rp *restful.Response) {
	Result = rq.PathParameter("param")
}