diff options
Diffstat (limited to 'src/cmd/godoc/codewalk.go')
| -rw-r--r-- | src/cmd/godoc/codewalk.go | 40 | 
1 files changed, 20 insertions, 20 deletions
| diff --git a/src/cmd/godoc/codewalk.go b/src/cmd/godoc/codewalk.go index 24087eb88..50043e2ab 100644 --- a/src/cmd/godoc/codewalk.go +++ b/src/cmd/godoc/codewalk.go @@ -17,7 +17,6 @@ import (  	"fmt"  	"http"  	"io" -	"io/ioutil"  	"log"  	"os"  	"regexp" @@ -42,7 +41,7 @@ func codewalk(w http.ResponseWriter, r *http.Request) {  	}  	// If directory exists, serve list of code walks. -	dir, err := os.Lstat(abspath) +	dir, err := fs.Lstat(abspath)  	if err == nil && dir.IsDirectory() {  		codewalkDir(w, r, relpath, abspath)  		return @@ -75,7 +74,7 @@ func codewalk(w http.ResponseWriter, r *http.Request) {  // A Codewalk represents a single codewalk read from an XML file.  type Codewalk struct { -	Title string "attr" +	Title string `xml:"attr"`  	File  []string  	Step  []*Codestep  } @@ -84,9 +83,9 @@ type Codewalk struct {  // A Codestep is a single step in a codewalk.  type Codestep struct {  	// Filled in from XML -	Src   string "attr" -	Title string "attr" -	XML   string "innerxml" +	Src   string `xml:"attr"` +	Title string `xml:"attr"` +	XML   string `xml:"innerxml"`  	// Derived from Src; not in XML.  	Err    os.Error @@ -114,8 +113,8 @@ func (st *Codestep) String() string {  // loadCodewalk reads a codewalk from the named XML file. -func loadCodewalk(file string) (*Codewalk, os.Error) { -	f, err := os.Open(file) +func loadCodewalk(filename string) (*Codewalk, os.Error) { +	f, err := fs.Open(filename)  	if err != nil {  		return nil, err  	} @@ -125,7 +124,7 @@ func loadCodewalk(file string) (*Codewalk, os.Error) {  	p.Entity = xml.HTMLEntity  	err = p.Unmarshal(cw, nil)  	if err != nil { -		return nil, &os.PathError{"parsing", file, err} +		return nil, &os.PathError{"parsing", filename, err}  	}  	// Compute file list, evaluate line numbers for addresses. @@ -135,8 +134,8 @@ func loadCodewalk(file string) (*Codewalk, os.Error) {  		if i < 0 {  			i = len(st.Src)  		} -		file := st.Src[0:i] -		data, err := ioutil.ReadFile(absolutePath(file, *goroot)) +		filename := st.Src[0:i] +		data, err := fs.ReadFile(absolutePath(filename, *goroot))  		if err != nil {  			st.Err = err  			continue @@ -158,8 +157,8 @@ func loadCodewalk(file string) (*Codewalk, os.Error) {  			st.Hi = byteToLine(data, hi-1)  		}  		st.Data = data -		st.File = file -		m[file] = true +		st.File = filename +		m[filename] = true  	}  	// Make list of files @@ -169,7 +168,7 @@ func loadCodewalk(file string) (*Codewalk, os.Error) {  		cw.File[i] = f  		i++  	} -	sort.SortStrings(cw.File) +	sort.Strings(cw.File)  	return cw, nil  } @@ -184,7 +183,7 @@ func codewalkDir(w http.ResponseWriter, r *http.Request, relpath, abspath string  		Title string  	} -	dir, err := ioutil.ReadDir(abspath) +	dir, err := fs.ReadDir(abspath)  	if err != nil {  		log.Print(err)  		serveError(w, r, relpath, err) @@ -192,14 +191,15 @@ func codewalkDir(w http.ResponseWriter, r *http.Request, relpath, abspath string  	}  	var v vector.Vector  	for _, fi := range dir { +		name := fi.Name()  		if fi.IsDirectory() { -			v.Push(&elem{fi.Name + "/", ""}) -		} else if strings.HasSuffix(fi.Name, ".xml") { -			cw, err := loadCodewalk(abspath + "/" + fi.Name) +			v.Push(&elem{name + "/", ""}) +		} else if strings.HasSuffix(name, ".xml") { +			cw, err := loadCodewalk(abspath + "/" + name)  			if err != nil {  				continue  			} -			v.Push(&elem{fi.Name[0 : len(fi.Name)-len(".xml")], cw.Title}) +			v.Push(&elem{name[0 : len(name)-len(".xml")], cw.Title})  		}  	} @@ -216,7 +216,7 @@ func codewalkDir(w http.ResponseWriter, r *http.Request, relpath, abspath string  // the usual godoc HTML wrapper.  func codewalkFileprint(w http.ResponseWriter, r *http.Request, f string) {  	abspath := absolutePath(f, *goroot) -	data, err := ioutil.ReadFile(abspath) +	data, err := fs.ReadFile(abspath)  	if err != nil {  		log.Print(err)  		serveError(w, r, f, err) | 
