debug/proc.install: container/vector.install fmt.install io.install os.install runtime.install strconv.install strings.install sync.install syscall.install
ebnf.install: container/vector.install go/scanner.install go/token.install os.install strconv.install unicode.install utf8.install
exec.install: os.install strings.install
-exvar.install: bytes.install fmt.install http.install log.install strconv.install sync.install
+expvar.install: bytes.install fmt.install http.install log.install strconv.install sync.install
flag.install: fmt.install os.install strconv.install
fmt.install: io.install os.install reflect.install strconv.install utf8.install
go/ast.install: go/token.install unicode.install utf8.install
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// The exvar package provides a standardized interface to public variables,
+// The expvar package provides a standardized interface to public variables,
// such as operation counters in servers. It exposes these variables via
// HTTP at /debug/vars in JSON format.
-package exvar
+package expvar
import (
"bytes";
return c
}
-func exvarHandler(c *http.Conn, req *http.Request) {
+func expvarHandler(c *http.Conn, req *http.Request) {
c.SetHeader("content-type", "application/json; charset=utf-8");
fmt.Fprintf(c, "{\n");
first := true;
}
func init() {
- http.Handle("/debug/vars", http.HandlerFunc(exvarHandler));
+ http.Handle("/debug/vars", http.HandlerFunc(expvarHandler));
}
import (
"bytes";
"bufio";
- "exvar";
+ "expvar";
"flag";
"fmt";
"io";
// hello world, the web server
-var helloRequests = exvar.NewInt("hello-requests");
+var helloRequests = expvar.NewInt("hello-requests");
func HelloServer(c *http.Conn, req *http.Request) {
helloRequests.Add(1);
io.WriteString(c, "hello, world!\n");
n int;
}
-// This makes Counter satisfy the exvar.Var interface, so we can export
+// This makes Counter satisfy the expvar.Var interface, so we can export
// it directly.
func (ctr *Counter) String() string {
return fmt.Sprintf("%d", ctr.n)
// simple file server
var webroot = flag.String("root", "/home/rsc", "web root directory")
-var pathVar = exvar.NewMap("file-requests");
+var pathVar = expvar.NewMap("file-requests");
func FileServer(c *http.Conn, req *http.Request) {
c.SetHeader("content-type", "text/plain; charset=utf-8");
pathVar.Add(req.Url.Path, 1);
// The counter is published as a variable directly.
ctr := new(Counter);
http.Handle("/counter", ctr);
- exvar.Publish("counter", ctr);
+ expvar.Publish("counter", ctr);
http.Handle("/go/", http.HandlerFunc(FileServer));
http.Handle("/flags", http.HandlerFunc(FlagServer));