Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: experimental/webtry/webtry.go

Issue 651343002: webtry: Check the result of os.Chdir(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package main 1 package main
2 2
3 import ( 3 import (
4 "bytes" 4 "bytes"
5 "crypto/md5" 5 "crypto/md5"
6 "database/sql" 6 "database/sql"
7 "encoding/base64" 7 "encoding/base64"
8 "encoding/binary" 8 "encoding/binary"
9 "encoding/json" 9 "encoding/json"
10 "flag" 10 "flag"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ret = append(ret, fmt.Sprintf("#line %d", i+1)) 132 ret = append(ret, fmt.Sprintf("#line %d", i+1))
133 ret = append(ret, line) 133 ret = append(ret, line)
134 } 134 }
135 return strings.Join(ret, "\n") 135 return strings.Join(ret, "\n")
136 } 136 }
137 137
138 func init() { 138 func init() {
139 rand.Seed(time.Now().UnixNano()) 139 rand.Seed(time.Now().UnixNano())
140 140
141 // Change the current working directory to the directory of the executab le. 141 // Change the current working directory to the directory of the executab le.
142 var err error
143 cwd, err := filepath.Abs(filepath.Dir(os.Args[0])) 142 cwd, err := filepath.Abs(filepath.Dir(os.Args[0]))
144 if err != nil { 143 if err != nil {
145 log.Fatal(err) 144 log.Fatal(err)
146 } 145 }
147 » os.Chdir(cwd) 146 » if err := os.Chdir(cwd); err != nil {
147 » » log.Fatal(err)
148 » }
148 149
149 codeTemplate = template.Must(template.ParseFiles(filepath.Join(cwd, "tem plates/template.cpp"))) 150 codeTemplate = template.Must(template.ParseFiles(filepath.Join(cwd, "tem plates/template.cpp")))
150 gypTemplate = template.Must(template.ParseFiles(filepath.Join(cwd, "temp lates/template.gyp"))) 151 gypTemplate = template.Must(template.ParseFiles(filepath.Join(cwd, "temp lates/template.gyp")))
151 indexTemplate = htemplate.Must(htemplate.ParseFiles( 152 indexTemplate = htemplate.Must(htemplate.ParseFiles(
152 filepath.Join(cwd, "templates/index.html"), 153 filepath.Join(cwd, "templates/index.html"),
153 filepath.Join(cwd, "templates/titlebar.html"), 154 filepath.Join(cwd, "templates/titlebar.html"),
154 filepath.Join(cwd, "templates/sidebar.html"), 155 filepath.Join(cwd, "templates/sidebar.html"),
155 filepath.Join(cwd, "templates/content.html"), 156 filepath.Join(cwd, "templates/content.html"),
156 filepath.Join(cwd, "templates/headercommon.html"), 157 filepath.Join(cwd, "templates/headercommon.html"),
157 filepath.Join(cwd, "templates/footercommon.html"), 158 filepath.Join(cwd, "templates/footercommon.html"),
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 http.HandleFunc("/sources/", autogzip.HandleFunc(sourcesHandler)) 903 http.HandleFunc("/sources/", autogzip.HandleFunc(sourcesHandler))
903 904
904 // Resources are served directly 905 // Resources are served directly
905 // TODO add support for caching/etags/gzip 906 // TODO add support for caching/etags/gzip
906 http.Handle("/res/", autogzip.Handle(http.FileServer(http.Dir("./")))) 907 http.Handle("/res/", autogzip.Handle(http.FileServer(http.Dir("./"))))
907 908
908 // TODO Break out /c/ as it's own handler. 909 // TODO Break out /c/ as it's own handler.
909 http.HandleFunc("/", autogzip.HandleFunc(mainHandler)) 910 http.HandleFunc("/", autogzip.HandleFunc(mainHandler))
910 log.Fatal(http.ListenAndServe(*port, nil)) 911 log.Fatal(http.ListenAndServe(*port, nil))
911 } 912 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698