1
0
mirror of https://github.com/golang/go synced 2024-11-25 10:27:57 -07:00

rename the public exvar package to be expvar.

R=rsc
DELTA=684  (324 added, 324 deleted, 36 changed)
OCL=35161
CL=35163
This commit is contained in:
Rob Pike 2009-09-30 13:11:33 -07:00
parent 164a7bceeb
commit 0632bb4ae5
6 changed files with 14 additions and 14 deletions

View File

@ -26,7 +26,7 @@ debug/gosym.install: debug/binary.install fmt.install os.install strconv.install
debug/proc.install: container/vector.install fmt.install io.install os.install runtime.install strconv.install strings.install sync.install syscall.install 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 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 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 flag.install: fmt.install os.install strconv.install
fmt.install: io.install os.install reflect.install strconv.install utf8.install fmt.install: io.install os.install reflect.install strconv.install utf8.install
go/ast.install: go/token.install unicode.install utf8.install go/ast.install: go/token.install unicode.install utf8.install

View File

@ -40,7 +40,7 @@ DIRS=\
debug/proc\ debug/proc\
ebnf\ ebnf\
exec\ exec\
exvar\ expvar\
flag\ flag\
fmt\ fmt\
go/ast\ go/ast\

View File

@ -4,8 +4,8 @@
include $(GOROOT)/src/Make.$(GOARCH) include $(GOROOT)/src/Make.$(GOARCH)
TARG=exvar TARG=expvar
GOFILES=\ GOFILES=\
exvar.go\ expvar.go\
include $(GOROOT)/src/Make.pkg include $(GOROOT)/src/Make.pkg

View File

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 // such as operation counters in servers. It exposes these variables via
// HTTP at /debug/vars in JSON format. // HTTP at /debug/vars in JSON format.
package exvar package expvar
import ( import (
"bytes"; "bytes";
@ -203,7 +203,7 @@ func Iter() <-chan KeyValue {
return c 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"); c.SetHeader("content-type", "application/json; charset=utf-8");
fmt.Fprintf(c, "{\n"); fmt.Fprintf(c, "{\n");
first := true; first := true;
@ -218,5 +218,5 @@ func exvarHandler(c *http.Conn, req *http.Request) {
} }
func init() { func init() {
http.Handle("/debug/vars", http.HandlerFunc(exvarHandler)); http.Handle("/debug/vars", http.HandlerFunc(expvarHandler));
} }

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package exvar package expvar
import ( import (
"json"; "json";

View File

@ -7,7 +7,7 @@ package main
import ( import (
"bytes"; "bytes";
"bufio"; "bufio";
"exvar"; "expvar";
"flag"; "flag";
"fmt"; "fmt";
"io"; "io";
@ -19,7 +19,7 @@ import (
// hello world, the web server // 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) { func HelloServer(c *http.Conn, req *http.Request) {
helloRequests.Add(1); helloRequests.Add(1);
io.WriteString(c, "hello, world!\n"); io.WriteString(c, "hello, world!\n");
@ -30,7 +30,7 @@ type Counter struct {
n int; 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. // it directly.
func (ctr *Counter) String() string { func (ctr *Counter) String() string {
return fmt.Sprintf("%d", ctr.n) return fmt.Sprintf("%d", ctr.n)
@ -56,7 +56,7 @@ func (ctr *Counter) ServeHTTP(c *http.Conn, req *http.Request) {
// simple file server // simple file server
var webroot = flag.String("root", "/home/rsc", "web root directory") 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) { func FileServer(c *http.Conn, req *http.Request) {
c.SetHeader("content-type", "text/plain; charset=utf-8"); c.SetHeader("content-type", "text/plain; charset=utf-8");
pathVar.Add(req.Url.Path, 1); pathVar.Add(req.Url.Path, 1);
@ -143,7 +143,7 @@ func main() {
// The counter is published as a variable directly. // The counter is published as a variable directly.
ctr := new(Counter); ctr := new(Counter);
http.Handle("/counter", ctr); http.Handle("/counter", ctr);
exvar.Publish("counter", ctr); expvar.Publish("counter", ctr);
http.Handle("/go/", http.HandlerFunc(FileServer)); http.Handle("/go/", http.HandlerFunc(FileServer));
http.Handle("/flags", http.HandlerFunc(FlagServer)); http.Handle("/flags", http.HandlerFunc(FlagServer));