]> Cypherpunks repositories - gostls13.git/commitdiff
gofix: make fix order explicit
authorRuss Cox <rsc@golang.org>
Thu, 13 Oct 2011 22:45:38 +0000 (18:45 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 13 Oct 2011 22:45:38 +0000 (18:45 -0400)
Also test only specific fixes, not all fixes.
This means we don't have to keep updating old
test cases to match later changes to the library.

I had to adjust some of the reflect test cases,
because they were implicitly testing
reflect+oserrorstring, not just reflect.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/5283042

49 files changed:
src/cmd/gofix/filepath.go
src/cmd/gofix/filepath_test.go
src/cmd/gofix/fix.go
src/cmd/gofix/httpfinalurl.go
src/cmd/gofix/httpfinalurl_test.go
src/cmd/gofix/httpfs.go
src/cmd/gofix/httpfs_test.go
src/cmd/gofix/httpheaders.go
src/cmd/gofix/httpheaders_test.go
src/cmd/gofix/httpserver.go
src/cmd/gofix/httpserver_test.go
src/cmd/gofix/imagecolor.go
src/cmd/gofix/imagecolor_test.go
src/cmd/gofix/imagenew.go
src/cmd/gofix/imagenew_test.go
src/cmd/gofix/iocopyn.go
src/cmd/gofix/iocopyn_test.go
src/cmd/gofix/main_test.go
src/cmd/gofix/math.go
src/cmd/gofix/math_test.go
src/cmd/gofix/netdial.go
src/cmd/gofix/netdial_test.go
src/cmd/gofix/netudpgroup.go
src/cmd/gofix/netudpgroup_test.go
src/cmd/gofix/oserrorstring.go
src/cmd/gofix/oserrorstring_test.go
src/cmd/gofix/osopen.go
src/cmd/gofix/osopen_test.go
src/cmd/gofix/procattr.go
src/cmd/gofix/procattr_test.go
src/cmd/gofix/reflect.go
src/cmd/gofix/reflect_test.go
src/cmd/gofix/signal.go
src/cmd/gofix/signal_test.go
src/cmd/gofix/sorthelpers.go
src/cmd/gofix/sorthelpers_test.go
src/cmd/gofix/sortslice.go
src/cmd/gofix/sortslice_test.go
src/cmd/gofix/stringssplit.go
src/cmd/gofix/stringssplit_test.go
src/cmd/gofix/testdata/reflect.decoder.go.in
src/cmd/gofix/testdata/reflect.encoder.go.in
src/cmd/gofix/testdata/reflect.export.go.in
src/cmd/gofix/testdata/reflect.print.go.in
src/cmd/gofix/testdata/reflect.read.go.in
src/cmd/gofix/testdata/reflect.scan.go.in
src/cmd/gofix/testdata/reflect.type.go.in
src/cmd/gofix/url.go
src/cmd/gofix/url_test.go

index 1d0ad68794129e9961057d526f6c33df65b9578e..3edccabfa6757cc5c69dc82f71257e5dba3baee6 100644 (file)
@@ -8,15 +8,13 @@ import (
        "go/ast"
 )
 
-func init() {
-       register(fix{
-               "filepath",
-               filepathFunc,
-               `Adapt code from filepath.[List]SeparatorString to string(filepath.[List]Separator).
+var filepathFix = fix{
+       "filepath",
+       filepathFunc,
+       `Adapt code from filepath.[List]SeparatorString to string(filepath.[List]Separator).
 
 http://codereview.appspot.com/4527090
 `,
-       })
 }
 
 func filepathFunc(f *ast.File) (fixed bool) {
index d170c3ae3ce8cde1b59edc6300e55770ca1edf01..37a2f5d9f0d514fc32fcff3fe2de2076f8b65627 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(filepathTests)
+       addTestCases(filepathTests, filepathFunc)
 }
 
 var filepathTests = []testCase{
index cc85ceafa30445d651688a17895a5af1ac29f990..6d15cc8dc7fb22cdba5596af08561359d341a818 100644 (file)
@@ -26,10 +26,33 @@ func (f fixlist) Len() int           { return len(f) }
 func (f fixlist) Swap(i, j int)      { f[i], f[j] = f[j], f[i] }
 func (f fixlist) Less(i, j int) bool { return f[i].name < f[j].name }
 
-var fixes fixlist
-
-func register(f fix) {
-       fixes = append(fixes, f)
+var fixes = fixlist{
+       // NOTE: This list must be in chronological order,
+       // so that code using APIs that changed multiple times
+       // can be updated in the correct order.
+       // Add new fixes to bottom of list.  Do not sort.
+       httpserverFix,
+       procattrFix,
+       netdialFix,
+       netlookupFix,
+       tlsdialFix,
+       osopenFix,
+       reflectFix,
+       httpFinalURLFix,
+       httpHeadersFix,
+       oserrorstringFix,
+       sortsliceFix,
+       filepathFix,
+       httpFileSystemFix,
+       stringssplitFix,
+       signalFix,
+       sorthelpersFix,
+       urlFix,
+       netudpgroupFix,
+       imagenewFix,
+       mathFix,
+       ioCopyNFix,
+       imagecolorFix,
 }
 
 // walk traverses the AST x, calling visit(y) for each node y in the tree but
index 9e6cbf6bc5790b75f155293dda97bf214e92b635..6051a2f3f9927b4a7b808e530792e4ce417e9936 100644 (file)
@@ -17,10 +17,6 @@ http://codereview.appspot.com/4535056/
 `,
 }
 
-func init() {
-       register(httpFinalURLFix)
-}
-
 func httpfinalurl(f *ast.File) bool {
        if !imports(f, "http") {
                return false
index 9e7d6242d68b2b2c52110a956387cf8df5f62171..9249f7e185784cb274b2d046d109ad6f1859edea 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(httpfinalurlTests)
+       addTestCases(httpfinalurlTests, httpfinalurl)
 }
 
 var httpfinalurlTests = []testCase{
index 7f27656809f86ca975b780d42f40d551ade1671d..317330619e20c2c770e4cad3d9f1e462a3655c4a 100644 (file)
@@ -18,10 +18,6 @@ http://codereview.appspot.com/4629047  http FileSystem interface
 `,
 }
 
-func init() {
-       register(httpFileSystemFix)
-}
-
 func httpfs(f *ast.File) bool {
        if !imports(f, "http") {
                return false
index d1804e93bf527dfa7ef3996691fc5cb9a698e673..dd8ef2cfd6908a077f8584c687637f5d69dd110c 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(httpFileSystemTests)
+       addTestCases(httpFileSystemTests, httpfs)
 }
 
 var httpFileSystemTests = []testCase{
index 8a9080e8e372eb03c3b08b63c414b0c89155c9fe..2e906d859c2b3841fe37ad55491a331a9b3f55b3 100644 (file)
@@ -17,10 +17,6 @@ http://codereview.appspot.com/4620049/
 `,
 }
 
-func init() {
-       register(httpHeadersFix)
-}
-
 func httpheaders(f *ast.File) bool {
        if !imports(f, "http") {
                return false
index cc82b5893609b173f3d41176c9b9a1e3951e6c6b..37506b82da0dcff754f685ecb9a41322790a2b76 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(httpHeadersTests)
+       addTestCases(httpHeadersTests, httpheaders)
 }
 
 var httpHeadersTests = []testCase{
index 37866e88b187fdabe8a6506f90ca3a5b470042e1..cf8d16a978eb45c8d8f74419029a6e74bcdbc997 100644 (file)
@@ -22,10 +22,6 @@ http://codereview.appspot.com/4248075  RemoteAddr, UsingTLS
 `,
 }
 
-func init() {
-       register(httpserverFix)
-}
-
 func httpserver(f *ast.File) bool {
        if !imports(f, "http") {
                return false
index 89bb4fa710f06c06fbaa11fac897883e96f5b9ad..b6ddff27e2fcef8bb4bb8b781427420c1785c3b9 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(httpserverTests)
+       addTestCases(httpserverTests, httpserver)
 }
 
 var httpserverTests = []testCase{
index d1cda335664f8dd000cd8d5f5fbf269ef3f203d8..d6171196d96bb6e609a5ef771ed67f391e4d6bcf 100644 (file)
@@ -8,15 +8,13 @@ import (
        "go/ast"
 )
 
-func init() {
-       register(fix{
-               "color",
-               color,
-               `Adapt code to types moved from image to color.
+var imagecolorFix = fix{
+       "imagecolor",
+       imagecolor,
+       `Adapt code to types moved from image to color.
 
 http://codereview.appspot.com/5132048
 `,
-       })
 }
 
 var colorRenames = []struct{ in, out string }{
@@ -44,7 +42,7 @@ var colorRenames = []struct{ in, out string }{
        {"Gray16ColorModel", "Gray16Model"},
 }
 
-func color(f *ast.File) (fixed bool) {
+func imagecolor(f *ast.File) (fixed bool) {
        if !imports(f, "image") {
                return
        }
index 3a3d4c6bf4d24ca7d213808181dbc4acc14ce727..c6236548170b703e174a0fc453c5d5f0371568e7 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(colorTests)
+       addTestCases(colorTests, imagecolor)
 }
 
 var colorTests = []testCase{
index 0b3c0a307864137de03f6f1cf642ad553ed50efa..07cbef5697df9674b343255636fea36d0b06f7a0 100644 (file)
@@ -17,10 +17,6 @@ http://codereview.appspot.com/4964073
 `,
 }
 
-func init() {
-       register(imagenewFix)
-}
-
 var imagenewFuncs = map[string]bool{
        "NewRGBA":    true,
        "NewRGBA64":  true,
index c45fc480de1470838015f6274674ba5acf5013b0..30abed23c285474539dada37bd99ef2c534f01bc 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(imagenewTests)
+       addTestCases(imagenewTests, imagenew)
 }
 
 var imagenewTests = []testCase{
index f4044605a70bc5dd12d46e03a9d4b6780f2c6896..f911dd740337c9ac5504e8cbc6a419c5f658f24f 100644 (file)
@@ -17,10 +17,6 @@ http://codereview.appspot.com/5157045
 `,
 }
 
-func init() {
-       register(ioCopyNFix)
-}
-
 func ioCopyN(f *ast.File) bool {
        if !imports(f, "io") {
                return false
index 27347766d9be10fb99b2e8e00afe38f1d087f700..f86fad763789cfbc180b18192e350fb41d2c96a7 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(ioCopyNTests)
+       addTestCases(ioCopyNTests, ioCopyN)
 }
 
 var ioCopyNTests = []testCase{
index 275778e5bebd3d14de30b24c43748fad68cf8a9f..077a15e52a447e1583ecd8a7cc9bd6c5113c280a 100644 (file)
@@ -22,7 +22,15 @@ type testCase struct {
 
 var testCases []testCase
 
-func addTestCases(t []testCase) {
+func addTestCases(t []testCase, fn func(*ast.File) bool) {
+       // Fill in fn to avoid repetition in definitions.
+       if fn != nil {
+               for i := range t {
+                       if t[i].Fn == nil {
+                               t[i].Fn = fn
+                       }
+               }
+       }
        testCases = append(testCases, t...)
 }
 
index 7d725bcd5b9e586eb503de2bdf2988154f7ea51b..8af4e87c7de778c9c67c383c00cd08e2c7f81ce9 100644 (file)
@@ -22,10 +22,6 @@ http://codereview.appspot.com/5158043
 `,
 }
 
-func init() {
-       register(mathFix)
-}
-
 var mathRenames = []struct{ in, out string }{
        {"Fabs", "Abs"},
        {"Fdim", "Dim"},
index d7d5f5653858829e2045ecd3a9a56b9933f66f66..b8d69d2f2f1351c28c146261be43a960a1fce7ed 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(mathTests)
+       addTestCases(mathTests, math)
 }
 
 var mathTests = []testCase{
index afa98953b973505fa47e0cf7070f71d87b779d9c..6984cdc37238e136b6dcca5aaa5476dc7dee316a 100644 (file)
@@ -35,12 +35,6 @@ http://codereview.appspot.com/4244055
 `,
 }
 
-func init() {
-       register(netdialFix)
-       register(tlsdialFix)
-       register(netlookupFix)
-}
-
 func netdial(f *ast.File) bool {
        if !imports(f, "net") {
                return false
index 272aa526a55a9347ef4fde404730599afd561060..43ca3874759311bf9d8f70a954d803fec56a2448 100644 (file)
@@ -1,12 +1,13 @@
 package main
 
 func init() {
-       addTestCases(netdialTests)
+       addTestCases(netdialTests, nil)
 }
 
 var netdialTests = []testCase{
        {
                Name: "netdial.0",
+               Fn:   netdial,
                In: `package main
 
 import "net"
@@ -29,6 +30,7 @@ func f() {
 
        {
                Name: "netlookup.0",
+               Fn:   netlookup,
                In: `package main
 
 import "net"
index 347452d43f9c24735ee0c18dc86f74564d7c7196..9bbb2d79199ff18749093824ec0c820fddf56612 100644 (file)
@@ -17,10 +17,6 @@ http://codereview.appspot.com/4815074
 `,
 }
 
-func init() {
-       register(netudpgroupFix)
-}
-
 func netudpgroup(f *ast.File) bool {
        if !imports(f, "net") {
                return false
index b3b5816da9f8855ae3c2e8acc2bbfbd7e6343f21..24f4abc167e6efc30cc5cd7eb31f3f94eb24227f 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(netudpgroupTests)
+       addTestCases(netudpgroupTests, netudpgroup)
 }
 
 var netudpgroupTests = []testCase{
index db39ee9dc6a288c4cd42022a1f3fde60dfada9e5..416333fc12174f8f5d2ca1bf22af435570331576 100644 (file)
@@ -17,10 +17,6 @@ http://codereview.appspot.com/4607052
 `,
 }
 
-func init() {
-       register(oserrorstringFix)
-}
-
 func oserrorstring(f *ast.File) bool {
        if !imports(f, "os") {
                return false
index 070d9222ba23d7bd1ab7d0743ad56bf5a802bc70..75551480c5d42f61552e576ceb814fce3f4203ae 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(oserrorstringTests)
+       addTestCases(oserrorstringTests, oserrorstring)
 }
 
 var oserrorstringTests = []testCase{
index 19c19b5b63d38ddaf55c77b0f7791da5378789e7..7e7fbbb037b9580478ff4c36277f0e5bc0a38665 100644 (file)
@@ -17,10 +17,6 @@ http://codereview.appspot.com/4357052
 `,
 }
 
-func init() {
-       register(osopenFix)
-}
-
 func osopen(f *ast.File) bool {
        if !imports(f, "os") {
                return false
index a33bcd4fb48554943cf509334f6f7588e5ec744d..5797adb7b269cf861ca997344a1adc2ad08e8a4e 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(osopenTests)
+       addTestCases(osopenTests, osopen)
 }
 
 var osopenTests = []testCase{
index 0e2190b1f4c95e3dfb5456f141b3897d8a5ae377..86a8fd10359b8ca6932d956b0f1602f318764bb7 100644 (file)
@@ -18,10 +18,6 @@ http://codereview.appspot.com/4253052
 `,
 }
 
-func init() {
-       register(procattrFix)
-}
-
 func procattr(f *ast.File) bool {
        if !imports(f, "os") && !imports(f, "syscall") {
                return false
index b973b9684df4b125e88c97490a42a95034520f4d..9e2b86e7443fb2c3b3a17d354df48383ce1bfb23 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(procattrTests)
+       addTestCases(procattrTests, procattr)
 }
 
 var procattrTests = []testCase{
index 3c8becaef3f0e1bad2219d483374d05fee6145d5..c292543ab8680d368975b19358fbb1ca641b9dfc 100644 (file)
@@ -25,10 +25,6 @@ http://codereview.appspot.com/4433066
 `,
 }
 
-func init() {
-       register(reflectFix)
-}
-
 // The reflect API change dropped the concrete types *reflect.ArrayType etc.
 // Any type assertions prior to method calls can be deleted:
 //     x.(*reflect.ArrayType).Len() -> x.Len()
index 00edf30e9eb76d8c56298cddce8423e8f0c8d203..b0e2fc20c34b6690b2776c2801e1cc3edfaa969a 100644 (file)
@@ -7,7 +7,7 @@ import (
 )
 
 func init() {
-       addTestCases(reflectTests())
+       addTestCases(reflectTests(), reflectFn)
 }
 
 func reflectTests() []testCase {
index 53c338851cbdca631a99e7da43badaa502cc5fca..aaad34825983224f9fe52411c2f47b5e1133b11c 100644 (file)
@@ -9,15 +9,13 @@ import (
        "strings"
 )
 
-func init() {
-       register(fix{
-               "signal",
-               signal,
-               `Adapt code to types moved from os/signal to signal.
+var signalFix = fix{
+       "signal",
+       signal,
+       `Adapt code to types moved from os/signal to signal.
 
 http://codereview.appspot.com/4437091
 `,
-       })
 }
 
 func signal(f *ast.File) (fixed bool) {
index 4abba3534957719f339d829adcf3029bb98ab5b3..7bca7d5c4d5963a232f9f513c47b8355b8a721b7 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(signalTests)
+       addTestCases(signalTests, signal)
 }
 
 var signalTests = []testCase{
index 4e89fa88f134bf4222fac23de283e1b69335c19a..74d0daa3a9f625294bd66b46cd092e0c5c8b863d 100644 (file)
@@ -8,13 +8,11 @@ import (
        "go/ast"
 )
 
-func init() {
-       register(fix{
-               "sorthelpers",
-               sorthelpers,
-               `Adapt code from sort.Sort[Ints|Float64s|Strings] to sort.[Ints|Float64s|Strings].
+var sorthelpersFix = fix{
+       "sorthelpers",
+       sorthelpers,
+       `Adapt code from sort.Sort[Ints|Float64s|Strings] to sort.[Ints|Float64s|Strings].
 `,
-       })
 }
 
 func sorthelpers(f *ast.File) (fixed bool) {
index 6c37858fd4159e7a0a777fe7848ea012d26ffc9e..dd6b58e033dd5f3f292a137b84cc18ca6d3417a0 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(sorthelpersTests)
+       addTestCases(sorthelpersTests, sorthelpers)
 }
 
 var sorthelpersTests = []testCase{
index 7cfa1696be3de0a25ba559728f62704b0add4bd7..847f0d57fb5970cf64eb8061660e2bade66ff994 100644 (file)
@@ -8,16 +8,14 @@ import (
        "go/ast"
 )
 
-func init() {
-       register(fix{
-               "sortslice",
-               sortslice,
-               `Adapt code from sort.[Float64|Int|String]Array to  sort.[Float64|Int|String]Slice.
+var sortsliceFix = fix{
+       "sortslice",
+       sortslice,
+       `Adapt code from sort.[Float64|Int|String]Array to  sort.[Float64|Int|String]Slice.
                
 http://codereview.appspot.com/4602054
 http://codereview.appspot.com/4639041
 `,
-       })
 }
 
 func sortslice(f *ast.File) (fixed bool) {
index 404feb26faef79cbfd6fe32f65b8f6caa824674d..7b745a2320af29038e432055b22354ed5871e407 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(sortsliceTests)
+       addTestCases(sortsliceTests, sortslice)
 }
 
 var sortsliceTests = []testCase{
index 4a1fe93d39a2a32fcf52475755e1ba1f68efabba..e3886dd729ea75104d8588c8e18473501c890c90 100644 (file)
@@ -18,10 +18,6 @@ http://codereview.appspot.com/4661051
 `,
 }
 
-func init() {
-       register(stringssplitFix)
-}
-
 func stringssplit(f *ast.File) bool {
        if !imports(f, "bytes") && !imports(f, "strings") {
                return false
index b925722af79d689c61616f0d38c8dcabc3c8a0a7..fa42b1bea96b816a62c475dc30057a09fc44d10c 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(stringssplitTests)
+       addTestCases(stringssplitTests, stringssplit)
 }
 
 var stringssplitTests = []testCase{
index 34364161aa3bf50ef5caa723aee93ae2df0d7066..0ce9b06fddc302769e628944a8a1afed98f6f727 100644 (file)
@@ -44,7 +44,7 @@ func NewDecoder(r io.Reader) *Decoder {
 func (dec *Decoder) recvType(id typeId) {
        // Have we already seen this type?  That's an error
        if id < firstUserId || dec.wireType[id] != nil {
-               dec.err = os.ErrorString("gob: duplicate type received")
+               dec.err = os.NewError("gob: duplicate type received")
                return
        }
 
@@ -143,7 +143,7 @@ func (dec *Decoder) decodeTypeSequence(isInterface bool) typeId {
                // will be absorbed by recvMessage.)
                if dec.buf.Len() > 0 {
                        if !isInterface {
-                               dec.err = os.ErrorString("extra data in buffer")
+                               dec.err = os.NewError("extra data in buffer")
                                break
                        }
                        dec.nextUint()
@@ -165,7 +165,7 @@ func (dec *Decoder) Decode(e interface{}) os.Error {
        // If e represents a value as opposed to a pointer, the answer won't
        // get back to the caller.  Make sure it's a pointer.
        if value.Type().Kind() != reflect.Ptr {
-               dec.err = os.ErrorString("gob: attempt to decode into a non-pointer")
+               dec.err = os.NewError("gob: attempt to decode into a non-pointer")
                return dec.err
        }
        return dec.DecodeValue(value)
index e52a4de29f7117c9f9b3d274a96835daaeb0de38..0202d79ac90b06171f1b32a724c8f2689e1e24af 100644 (file)
@@ -50,7 +50,7 @@ func (enc *Encoder) popWriter() {
 }
 
 func (enc *Encoder) badType(rt reflect.Type) {
-       enc.setError(os.ErrorString("gob: can't encode type " + rt.String()))
+       enc.setError(os.NewError("gob: can't encode type " + rt.String()))
 }
 
 func (enc *Encoder) setError(err os.Error) {
index e91e777e306ee1ac58435ce3d8f6e73940fad5b9..495fc46b6a3aaa80f9714124875babc31706757f 100644 (file)
@@ -343,20 +343,20 @@ func (exp *Exporter) Sync(timeout int64) os.Error {
 func checkChan(chT interface{}, dir Dir) (*reflect.ChanValue, os.Error) {
        chanType, ok := reflect.Typeof(chT).(*reflect.ChanType)
        if !ok {
-               return nil, os.ErrorString("not a channel")
+               return nil, os.NewError("not a channel")
        }
        if dir != Send && dir != Recv {
-               return nil, os.ErrorString("unknown channel direction")
+               return nil, os.NewError("unknown channel direction")
        }
        switch chanType.Dir() {
        case reflect.BothDir:
        case reflect.SendDir:
                if dir != Recv {
-                       return nil, os.ErrorString("to import/export with Send, must provide <-chan")
+                       return nil, os.NewError("to import/export with Send, must provide <-chan")
                }
        case reflect.RecvDir:
                if dir != Send {
-                       return nil, os.ErrorString("to import/export with Recv, must provide chan<-")
+                       return nil, os.NewError("to import/export with Recv, must provide chan<-")
                }
        }
        return reflect.NewValue(chT).(*reflect.ChanValue), nil
@@ -376,7 +376,7 @@ func (exp *Exporter) Export(name string, chT interface{}, dir Dir) os.Error {
        defer exp.mu.Unlock()
        _, present := exp.names[name]
        if present {
-               return os.ErrorString("channel name already being exported:" + name)
+               return os.NewError("channel name already being exported:" + name)
        }
        exp.names[name] = &chanDir{ch, dir}
        return nil
@@ -393,7 +393,7 @@ func (exp *Exporter) Hangup(name string) os.Error {
        // TODO drop all instances of channel from client sets
        exp.mu.Unlock()
        if !ok {
-               return os.ErrorString("netchan export: hangup: no such channel: " + name)
+               return os.NewError("netchan export: hangup: no such channel: " + name)
        }
        chDir.ch.Close()
        return nil
index cba1df29673d1e21a2e2c55b1c5670cfe4c103ff..6c9b8e4f9aec51e0fbb031114c3345518f809471 100644 (file)
@@ -185,7 +185,7 @@ func Sprintf(format string, a ...interface{}) string {
 // Errorf formats according to a format specifier and returns the string 
 // converted to an os.ErrorString, which satisfies the os.Error interface.
 func Errorf(format string, a ...interface{}) os.Error {
-       return os.ErrorString(Sprintf(format, a...))
+       return os.NewError(Sprintf(format, a...))
 }
 
 // These routines do not take a format string
index 9ae3bb8eee91a08dcd121a4d6fc15ba6d4102a10..487994ac6e53872e87cde7ca908d9c0977d77699 100644 (file)
@@ -244,7 +244,7 @@ func (p *Parser) unmarshal(val reflect.Value, start *StartElement) os.Error {
 
        switch v := val.(type) {
        default:
-               return os.ErrorString("unknown type " + v.Type().String())
+               return os.NewError("unknown type " + v.Type().String())
 
        case *reflect.SliceValue:
                typ := v.Type().(*reflect.SliceType)
@@ -483,7 +483,7 @@ Loop:
        case nil:
                // Probably a comment, handled below
        default:
-               return os.ErrorString("cannot happen: unknown type " + t.Type().String())
+               return os.NewError("cannot happen: unknown type " + t.Type().String())
        case *reflect.IntValue:
                if !getInt64() {
                        return err
index 83650e605d16b57a3a81fb6c7df1500c2a46fbd0..51898181f97d2ea7dfe055f4cbd9cde6c62b2511 100644 (file)
@@ -167,7 +167,7 @@ type ssave struct {
 // satisfies io.Reader. It will never be called when used as
 // intended, so there is no need to make it actually work.
 func (s *ss) Read(buf []byte) (n int, err os.Error) {
-       return 0, os.ErrorString("ScanState's Read should not be called. Use ReadRune")
+       return 0, os.NewError("ScanState's Read should not be called. Use ReadRune")
 }
 
 func (s *ss) ReadRune() (rune int, size int, err os.Error) {
@@ -240,7 +240,7 @@ func (s *ss) error(err os.Error) {
 }
 
 func (s *ss) errorString(err string) {
-       panic(scanError{os.ErrorString(err)})
+       panic(scanError{os.NewError(err)})
 }
 
 func (s *ss) Token(skipSpace bool, f func(int) bool) (tok []byte, err os.Error) {
@@ -424,8 +424,8 @@ func (s *ss) typeError(field interface{}, expected string) {
        s.errorString("expected field of type pointer to " + expected + "; found " + reflect.Typeof(field).String())
 }
 
-var complexError = os.ErrorString("syntax error scanning complex number")
-var boolError = os.ErrorString("syntax error scanning boolean")
+var complexError = os.NewError("syntax error scanning complex number")
+var boolError = os.NewError("syntax error scanning boolean")
 
 // consume reads the next rune in the input and reports whether it is in the ok string.
 // If accept is true, it puts the character into the input token.
index 305d41980a54ceb46d0c84912ade040aefe691e2..7ed7002abfd6b98a6249a64f7ffdfd650acf9664 100644 (file)
@@ -67,7 +67,7 @@ func validUserType(rt reflect.Type) (ut *userTypeInfo, err os.Error) {
                ut.base = pt.Elem()
                if ut.base == slowpoke { // ut.base lapped slowpoke
                        // recursive pointer type.
-                       return nil, os.ErrorString("can't represent recursive pointer type " + ut.base.String())
+                       return nil, os.NewError("can't represent recursive pointer type " + ut.base.String())
                }
                if ut.indir%2 == 0 {
                        slowpoke = slowpoke.(*reflect.PtrType).Elem()
@@ -524,7 +524,7 @@ func newTypeObject(name string, ut *userTypeInfo, rt reflect.Type) (gobType, os.
                return st, nil
 
        default:
-               return nil, os.ErrorString("gob NewTypeObject can't handle type: " + rt.String())
+               return nil, os.NewError("gob NewTypeObject can't handle type: " + rt.String())
        }
        return nil, nil
 }
index 7135d8edf11ebfe6cfd016257dd503c3f02dc88f..455b544b630fbd37faeca920ca4b65e37bd35817 100644 (file)
@@ -22,10 +22,6 @@ http://codereview.appspot.com/4893043
 `,
 }
 
-func init() {
-       register(urlFix)
-}
-
 var urlRenames = []struct{ in, out string }{
        {"URL", "URL"},
        {"ParseURL", "Parse"},
index 8d9542cbca036a4a4cb14b5a1b9538bfe566954b..ca886e983e8221d4a56befa639e26b9a4b3dec1a 100644 (file)
@@ -5,7 +5,7 @@
 package main
 
 func init() {
-       addTestCases(urlTests)
+       addTestCases(urlTests, url)
 }
 
 var urlTests = []testCase{