non-pkg: gofix -r error -force=error
R=golang-dev, iant, r, r
CC=golang-dev
https://golang.org/cl/5307066
diff --git a/doc/codelab/wiki/final-noclosure.go b/doc/codelab/wiki/final-noclosure.go
index 067f502..47f84a7 100644
--- a/doc/codelab/wiki/final-noclosure.go
+++ b/doc/codelab/wiki/final-noclosure.go
@@ -1,9 +1,9 @@
package main
import (
+ "errors"
"http"
"io/ioutil"
- "os"
"regexp"
"template"
)
@@ -13,12 +13,12 @@
Body []byte
}
-func (p *Page) save() os.Error {
+func (p *Page) save() error {
filename := p.Title + ".txt"
return ioutil.WriteFile(filename, p.Body, 0600)
}
-func loadPage(title string) (*Page, os.Error) {
+func loadPage(title string) (*Page, error) {
filename := title + ".txt"
body, err := ioutil.ReadFile(filename)
if err != nil {
@@ -61,21 +61,21 @@
p := &Page{Title: title, Body: []byte(body)}
err = p.save()
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.Redirect(w, r, "/view/"+title, http.StatusFound)
}
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
- t, err := template.ParseFile(tmpl+".html")
+ t, err := template.ParseFile(tmpl + ".html")
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
err = t.Execute(w, p)
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
@@ -83,11 +83,11 @@
var titleValidator = regexp.MustCompile("^[a-zA-Z0-9]+$")
-func getTitle(w http.ResponseWriter, r *http.Request) (title string, err os.Error) {
+func getTitle(w http.ResponseWriter, r *http.Request) (title string, err error) {
title = r.URL.Path[lenPath:]
if !titleValidator.MatchString(title) {
http.NotFound(w, r)
- err = os.NewError("Invalid Page Title")
+ err = errors.New("Invalid Page Title")
}
return
}
diff --git a/doc/codelab/wiki/final-noerror.go b/doc/codelab/wiki/final-noerror.go
index b8edbee..69e1912 100644
--- a/doc/codelab/wiki/final-noerror.go
+++ b/doc/codelab/wiki/final-noerror.go
@@ -3,7 +3,6 @@
import (
"http"
"io/ioutil"
- "os"
"template"
)
@@ -12,12 +11,12 @@
Body []byte
}
-func (p *Page) save() os.Error {
+func (p *Page) save() error {
filename := p.Title + ".txt"
return ioutil.WriteFile(filename, p.Body, 0600)
}
-func loadPage(title string) (*Page, os.Error) {
+func loadPage(title string) (*Page, error) {
filename := title + ".txt"
body, err := ioutil.ReadFile(filename)
if err != nil {
diff --git a/doc/codelab/wiki/final-parsetemplate.go b/doc/codelab/wiki/final-parsetemplate.go
index f25012e..d3675a0 100644
--- a/doc/codelab/wiki/final-parsetemplate.go
+++ b/doc/codelab/wiki/final-parsetemplate.go
@@ -3,7 +3,6 @@
import (
"http"
"io/ioutil"
- "os"
"regexp"
"template"
)
@@ -13,12 +12,12 @@
Body []byte
}
-func (p *Page) save() os.Error {
+func (p *Page) save() error {
filename := p.Title + ".txt"
return ioutil.WriteFile(filename, p.Body, 0600)
}
-func loadPage(title string) (*Page, os.Error) {
+func loadPage(title string) (*Page, error) {
filename := title + ".txt"
body, err := ioutil.ReadFile(filename)
if err != nil {
@@ -49,7 +48,7 @@
p := &Page{Title: title, Body: []byte(body)}
err := p.save()
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.Redirect(w, r, "/view/"+title, http.StatusFound)
@@ -58,12 +57,12 @@
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
t, err := template.ParseFile(tmpl+".html", nil)
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
err = t.Execute(w, p)
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
diff --git a/doc/codelab/wiki/final-template.go b/doc/codelab/wiki/final-template.go
index aab536e..4b5c44e 100644
--- a/doc/codelab/wiki/final-template.go
+++ b/doc/codelab/wiki/final-template.go
@@ -3,7 +3,6 @@
import (
"http"
"io/ioutil"
- "os"
"template"
)
@@ -12,12 +11,12 @@
Body []byte
}
-func (p *Page) save() os.Error {
+func (p *Page) save() error {
filename := p.Title + ".txt"
return ioutil.WriteFile(filename, p.Body, 0600)
}
-func loadPage(title string) (*Page, os.Error) {
+func loadPage(title string) (*Page, error) {
filename := title + ".txt"
body, err := ioutil.ReadFile(filename)
if err != nil {
diff --git a/doc/codelab/wiki/final.go b/doc/codelab/wiki/final.go
index 47a4c34..11620af 100644
--- a/doc/codelab/wiki/final.go
+++ b/doc/codelab/wiki/final.go
@@ -3,7 +3,6 @@
import (
"http"
"io/ioutil"
- "os"
"regexp"
"template"
)
@@ -13,12 +12,12 @@
Body []byte
}
-func (p *Page) save() os.Error {
+func (p *Page) save() error {
filename := p.Title + ".txt"
return ioutil.WriteFile(filename, p.Body, 0600)
}
-func loadPage(title string) (*Page, os.Error) {
+func loadPage(title string) (*Page, error) {
filename := title + ".txt"
body, err := ioutil.ReadFile(filename)
if err != nil {
@@ -49,7 +48,7 @@
p := &Page{Title: title, Body: []byte(body)}
err := p.save()
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.Redirect(w, r, "/view/"+title, http.StatusFound)
@@ -59,7 +58,7 @@
func init() {
for _, tmpl := range []string{"edit", "view"} {
- t := template.Must(template.ParseFile(tmpl+".html"))
+ t := template.Must(template.ParseFile(tmpl + ".html"))
templates[tmpl] = t
}
}
@@ -67,7 +66,7 @@
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
err := templates[tmpl].Execute(w, p)
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
diff --git a/doc/codelab/wiki/get.go b/doc/codelab/wiki/get.go
index c36684e..723484d 100644
--- a/doc/codelab/wiki/get.go
+++ b/doc/codelab/wiki/get.go
@@ -32,7 +32,7 @@
log.Fatal("no url supplied")
}
var r *http.Response
- var err os.Error
+ var err error
if *post != "" {
b := strings.NewReader(*post)
r, err = http.Post(url, "application/x-www-form-urlencoded", b)
diff --git a/doc/codelab/wiki/index.html b/doc/codelab/wiki/index.html
index 50e9db5..21248c1 100644
--- a/doc/codelab/wiki/index.html
+++ b/doc/codelab/wiki/index.html
@@ -98,7 +98,7 @@
</p>
<pre>
-func (p *Page) save() os.Error {
+func (p *Page) save() error {
filename := p.Title + ".txt"
return ioutil.WriteFile(filename, p.Body, 0600)
}
@@ -165,7 +165,7 @@
</p>
<pre>
-func loadPage(title string) (*Page, os.Error) {
+func loadPage(title string) (*Page, error) {
filename := title + ".txt"
body, err := ioutil.ReadFile(filename)
if err != nil {
@@ -645,12 +645,12 @@
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
t, err := template.ParseFile(tmpl+".html", nil)
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
err = t.Execute(w, p)
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
</pre>
@@ -675,7 +675,7 @@
p := &Page{Title: title, Body: []byte(body)}
err = p.save()
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.Redirect(w, r, "/view/"+title, http.StatusFound)
@@ -741,7 +741,7 @@
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
err := templates[tmpl].Execute(w, p)
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
</pre>
@@ -777,11 +777,11 @@
</p>
<pre>
-func getTitle(w http.ResponseWriter, r *http.Request) (title string, err os.Error) {
+func getTitle(w http.ResponseWriter, r *http.Request) (title string, err error) {
title = r.URL.Path[lenPath:]
if !titleValidator.MatchString(title) {
http.NotFound(w, r)
- err = os.NewError("Invalid Page Title")
+ err = errors.New("Invalid Page Title")
}
return
}
@@ -833,7 +833,7 @@
p := &Page{Title: title, Body: []byte(body)}
err = p.save()
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.Redirect(w, r, "/view/"+title, http.StatusFound)
@@ -958,7 +958,7 @@
p := &Page{Title: title, Body: []byte(body)}
err := p.save()
if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.Redirect(w, r, "/view/"+title, http.StatusFound)
diff --git a/doc/codelab/wiki/notemplate.go b/doc/codelab/wiki/notemplate.go
index 9cbe9ad..d2deec11 100644
--- a/doc/codelab/wiki/notemplate.go
+++ b/doc/codelab/wiki/notemplate.go
@@ -4,7 +4,6 @@
"fmt"
"http"
"io/ioutil"
- "os"
)
type Page struct {
@@ -12,12 +11,12 @@
Body []byte
}
-func (p *Page) save() os.Error {
+func (p *Page) save() error {
filename := p.Title + ".txt"
return ioutil.WriteFile(filename, p.Body, 0600)
}
-func loadPage(title string) (*Page, os.Error) {
+func loadPage(title string) (*Page, error) {
filename := title + ".txt"
body, err := ioutil.ReadFile(filename)
if err != nil {
diff --git a/doc/codelab/wiki/part1-noerror.go b/doc/codelab/wiki/part1-noerror.go
index 14cfc32..c70318a 100644
--- a/doc/codelab/wiki/part1-noerror.go
+++ b/doc/codelab/wiki/part1-noerror.go
@@ -3,7 +3,6 @@
import (
"fmt"
"io/ioutil"
- "os"
)
type Page struct {
@@ -11,7 +10,7 @@
Body []byte
}
-func (p *Page) save() os.Error {
+func (p *Page) save() error {
filename := p.Title + ".txt"
return ioutil.WriteFile(filename, p.Body, 0600)
}
diff --git a/doc/codelab/wiki/part1.go b/doc/codelab/wiki/part1.go
index 4b0654f..b3fb750 100644
--- a/doc/codelab/wiki/part1.go
+++ b/doc/codelab/wiki/part1.go
@@ -3,7 +3,6 @@
import (
"fmt"
"io/ioutil"
- "os"
)
type Page struct {
@@ -11,12 +10,12 @@
Body []byte
}
-func (p *Page) save() os.Error {
+func (p *Page) save() error {
filename := p.Title + ".txt"
return ioutil.WriteFile(filename, p.Body, 0600)
}
-func loadPage(title string) (*Page, os.Error) {
+func loadPage(title string) (*Page, error) {
filename := title + ".txt"
body, err := ioutil.ReadFile(filename)
if err != nil {
diff --git a/doc/codelab/wiki/part2.go b/doc/codelab/wiki/part2.go
index d57c3a0..a192089 100644
--- a/doc/codelab/wiki/part2.go
+++ b/doc/codelab/wiki/part2.go
@@ -4,7 +4,6 @@
"fmt"
"http"
"io/ioutil"
- "os"
)
type Page struct {
@@ -12,12 +11,12 @@
Body []byte
}
-func (p *Page) save() os.Error {
+func (p *Page) save() error {
filename := p.Title + ".txt"
return ioutil.WriteFile(filename, p.Body, 0600)
}
-func loadPage(title string) (*Page, os.Error) {
+func loadPage(title string) (*Page, error) {
filename := title + ".txt"
body, err := ioutil.ReadFile(filename)
if err != nil {