// Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package rpc/* Some HTML presented at http://machine:port/debug/rpc Lists services, their methods, and some statistics, still rudimentary.*/import ()const debugText = `<html> <body> <title>Services</title> {{range .}} <hr> Service {{.Name}} <hr> <table> <th align=center>Method</th><th align=center>Calls</th> {{range .Method}} <tr> <td align=left font=fixed>{{.Name}}({{.Type.ArgType}}, {{.Type.ReplyType}}) error</td> <td align=center>{{.Type.NumCalls}}</td> </tr> {{end}} </table> {{end}} </body> </html>`var debug = template.Must(template.New("RPC debug").Parse(debugText))// If set, print log statements for internal and I/O errors.var debugLog = falsetype debugMethod struct { Type *methodType Name string}type methodArray []debugMethodtype debugService struct { Service *service Name string Method methodArray}type serviceArray []debugServicefunc ( serviceArray) () int { returnlen() }func ( serviceArray) (, int) bool { return [].Name < [].Name }func ( serviceArray) (, int) { [], [] = [], [] }func ( methodArray) () int { returnlen() }func ( methodArray) (, int) bool { return [].Name < [].Name }func ( methodArray) (, int) { [], [] = [], [] }type debugHTTP struct { *Server}// Runs at /debug/rpcfunc ( debugHTTP) ( http.ResponseWriter, *http.Request) {// Build a sorted version of the data.varserviceArray .serviceMap.Range(func(, any) bool { := .(*service) := debugService{, .(string), make(methodArray, 0, len(.method))}for , := range .method { .Method = append(.Method, debugMethod{, }) }sort.Sort(.Method) = append(, )returntrue })sort.Sort() := debug.Execute(, )if != nil {fmt.Fprintln(, "rpc: error executing template:", .Error()) }}
The pages are generated with Goldsv0.6.6. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.