@@ -58,50 +58,50 @@ const (
5858var (
5959 // file system to serve
6060 // (with e.g.: zip -r go.zip $GOROOT -i \*.go -i \*.html -i \*.css -i \*.js -i \*.txt -i \*.c -i \*.h -i \*.s -i \*.png -i \*.jpg -i \*.sh -i favicon.ico)
61- zipfile = flag .String ("zip" , "" , "zip file providing the file system to serve; disabled if empty" )
61+ flagZipfile = flag .String ("zip" , "" , "zip file providing the file system to serve; disabled if empty" )
6262
6363 // file-based index
64- writeIndex = flag .Bool ("write_index" , false , "write index to a file; the file name must be specified with -index_files" )
64+ flagWriteIndex = flag .Bool ("write_index" , false , "write index to a file; the file name must be specified with -index_files" )
6565
66- analysisFlag = flag .String ("analysis" , "" , `comma-separated list of analyses to perform (supported: type, pointer). See http://golang.org/lib/godoc/analysis/help.html` )
66+ flagAnalysisFlag = flag .String ("analysis" , "" , `comma-separated list of analyses to perform (supported: type, pointer). See http://golang.org/lib/godoc/analysis/help.html` )
6767
6868 // network
69- httpAddr = flag .String ("http" , "" , "HTTP service address (e.g., '" + defaultAddr + "')" )
70- serverAddr = flag .String ("server" , "" , "webserver address for command line searches" )
69+ flagHttpAddr = flag .String ("http" , "" , "HTTP service address (e.g., '" + defaultAddr + "')" )
70+ flagServerAddr = flag .String ("server" , "" , "webserver address for command line searches" )
7171
7272 // layout control
73- html = flag .Bool ("html" , false , "print HTML in command-line mode" )
74- srcMode = flag .Bool ("src" , false , "print (exported) source in command-line mode" )
75- urlFlag = flag .String ("url" , "" , "print HTML for named URL" )
73+ flagHtml = flag .Bool ("html" , false , "print HTML in command-line mode" )
74+ flagSrcMode = flag .Bool ("src" , false , "print (exported) source in command-line mode" )
75+ flagUrlFlag = flag .String ("url" , "" , "print HTML for named URL" )
7676
7777 // command-line searches
78- query = flag .Bool ("q" , false , "arguments are considered search queries" )
78+ flagQuery = flag .Bool ("q" , false , "arguments are considered search queries" )
7979
80- verbose = flag .Bool ("v" , false , "verbose mode" )
80+ flagVerbose = flag .Bool ("v" , false , "verbose mode" )
8181
8282 // file system roots
8383 // TODO(gri) consider the invariant that goroot always end in '/'
84- goroot = flag .String ("goroot" , runtime .GOROOT (), "Go root directory" )
84+ flagGoroot = flag .String ("goroot" , runtime .GOROOT (), "Go root directory" )
8585
8686 // layout control
87- tabWidth = flag .Int ("tabwidth" , 4 , "tab width" )
88- showTimestamps = flag .Bool ("timestamps" , false , "show timestamps with directory listings" )
89- templateDir = flag .String ("templates" , "" , "directory containing alternate template files" )
90- showPlayground = flag .Bool ("play" , false , "enable playground in web interface" )
91- showExamples = flag .Bool ("ex" , false , "show examples in command line mode" )
92- declLinks = flag .Bool ("links" , true , "link identifiers to their declarations" )
87+ flagTabWidth = flag .Int ("tabwidth" , 4 , "tab width" )
88+ flagShowTimestamps = flag .Bool ("timestamps" , false , "show timestamps with directory listings" )
89+ flagTemplateDir = flag .String ("templates" , "" , "directory containing alternate template files" )
90+ flagShowPlayground = flag .Bool ("play" , false , "enable playground in web interface" )
91+ flagShowExamples = flag .Bool ("ex" , false , "show examples in command line mode" )
92+ flagDeclLinks = flag .Bool ("links" , true , "link identifiers to their declarations" )
9393
9494 // search index
95- indexEnabled = flag .Bool ("index" , false , "enable search index" )
96- indexFiles = flag .String ("index_files" , "" , "glob pattern specifying index files; if not empty, the index is read from these files in sorted order" )
97- maxResults = flag .Int ("maxresults" , 10000 , "maximum number of full text search results shown" )
98- indexThrottle = flag .Float64 ("index_throttle" , 0.75 , "index throttle value; 0.0 = no time allocated, 1.0 = full throttle" )
95+ flagIndexEnabled = flag .Bool ("index" , false , "enable search index" )
96+ flagIndexFiles = flag .String ("index_files" , "" , "glob pattern specifying index files; if not empty, the index is read from these files in sorted order" )
97+ flagMaxResults = flag .Int ("maxresults" , 10000 , "maximum number of full text search results shown" )
98+ flagIndexThrottle = flag .Float64 ("index_throttle" , 0.75 , "index throttle value; 0.0 = no time allocated, 1.0 = full throttle" )
9999
100100 // source code notes
101- notesRx = flag .String ("notes" , "BUG" , "regular expression matching note markers to show" )
101+ flagNotesRx = flag .String ("notes" , "BUG" , "regular expression matching note markers to show" )
102102
103103 // local language
104- lang = flag .String ("lang" , "" , "local language" )
104+ flagLang = flag .String ("lang" , "" , "local language" )
105105)
106106
107107func usage () {
@@ -121,7 +121,7 @@ func loggingHandler(h http.Handler) http.Handler {
121121
122122func handleURLFlag () {
123123 // Try up to 10 fetches, following redirects.
124- urlstr := * urlFlag
124+ urlstr := * flagUrlFlag
125125 for i := 0 ; i < 10 ; i ++ {
126126 // Prepare request.
127127 u , err := url .Parse (urlstr )
@@ -157,16 +157,16 @@ func handleURLFlag() {
157157
158158func runGodoc () {
159159 // Determine file system to use.
160- local .Init (* goroot , * zipfile , * templateDir , build .Default .GOPATH )
160+ local .Init (* flagGoroot , * flagZipfile , * flagTemplateDir , build .Default .GOPATH )
161161 fs .Bind ("/" , local .RootFS (), "/" , vfs .BindReplace )
162- fs .Bind ("/lib/godoc" , local .StaticFS (* lang ), "/" , vfs .BindReplace )
163- fs .Bind ("/doc" , local .DocumentFS (* lang ), "/" , vfs .BindReplace )
162+ fs .Bind ("/lib/godoc" , local .StaticFS (* flagLang ), "/" , vfs .BindReplace )
163+ fs .Bind ("/doc" , local .DocumentFS (* flagLang ), "/" , vfs .BindReplace )
164164
165- httpMode := * httpAddr != ""
165+ httpMode := * flagHttpAddr != ""
166166
167167 var typeAnalysis , pointerAnalysis bool
168- if * analysisFlag != "" {
169- for _ , a := range strings .Split (* analysisFlag , "," ) {
168+ if * flagAnalysisFlag != "" {
169+ for _ , a := range strings .Split (* flagAnalysisFlag , "," ) {
170170 switch a {
171171 case "type" :
172172 typeAnalysis = true
@@ -182,62 +182,62 @@ func runGodoc() {
182182
183183 // translate hook
184184 corpus .SummarizePackage = func (importPath string ) (summary string , showList , ok bool ) {
185- if pkg := local .Package (* lang , importPath ); pkg != nil {
185+ if pkg := local .Package (* flagLang , importPath ); pkg != nil {
186186 summary = doc .Synopsis (pkg .Doc )
187187 }
188188 ok = (summary != "" )
189189 return
190190 }
191191 corpus .TranslateDocPackage = func (pkg * doc.Package ) * doc.Package {
192- return local .Package (* lang , pkg .ImportPath , pkg )
192+ return local .Package (* flagLang , pkg .ImportPath , pkg )
193193 }
194194
195- corpus .Verbose = * verbose
196- corpus .MaxResults = * maxResults
197- corpus .IndexEnabled = * indexEnabled && httpMode
198- if * maxResults == 0 {
195+ corpus .Verbose = * flagVerbose
196+ corpus .MaxResults = * flagMaxResults
197+ corpus .IndexEnabled = * flagIndexEnabled && httpMode
198+ if * flagMaxResults == 0 {
199199 corpus .IndexFullText = false
200200 }
201- corpus .IndexFiles = * indexFiles
202- corpus .IndexThrottle = * indexThrottle
203- if * writeIndex {
201+ corpus .IndexFiles = * flagIndexFiles
202+ corpus .IndexThrottle = * flagIndexThrottle
203+ if * flagWriteIndex {
204204 corpus .IndexThrottle = 1.0
205205 corpus .IndexEnabled = true
206206 }
207- if * writeIndex || httpMode || * urlFlag != "" {
207+ if * flagWriteIndex || httpMode || * flagUrlFlag != "" {
208208 if err := corpus .Init (); err != nil {
209209 log .Fatal (err )
210210 }
211211 }
212212
213213 pres = godoc .NewPresentation (corpus )
214- pres .TabWidth = * tabWidth
215- pres .ShowTimestamps = * showTimestamps
216- pres .ShowPlayground = * showPlayground
217- pres .ShowExamples = * showExamples
218- pres .DeclLinks = * declLinks
219- pres .SrcMode = * srcMode
220- pres .HTMLMode = * html
221- if * notesRx != "" {
222- pres .NotesRx = regexp .MustCompile (* notesRx )
214+ pres .TabWidth = * flagTabWidth
215+ pres .ShowTimestamps = * flagShowTimestamps
216+ pres .ShowPlayground = * flagShowPlayground
217+ pres .ShowExamples = * flagShowExamples
218+ pres .DeclLinks = * flagDeclLinks
219+ pres .SrcMode = * flagSrcMode
220+ pres .HTMLMode = * flagHtml
221+ if * flagNotesRx != "" {
222+ pres .NotesRx = regexp .MustCompile (* flagNotesRx )
223223 }
224224
225- readTemplates (pres , httpMode || * urlFlag != "" )
225+ readTemplates (pres , httpMode || * flagUrlFlag != "" )
226226 registerHandlers (pres )
227227
228- if * writeIndex {
228+ if * flagWriteIndex {
229229 // Write search index and exit.
230- if * indexFiles == "" {
230+ if * flagIndexFiles == "" {
231231 log .Fatal ("no index file specified" )
232232 }
233233
234234 log .Println ("initialize file systems" )
235- * verbose = true // want to see what happens
235+ * flagVerbose = true // want to see what happens
236236
237237 corpus .UpdateIndex ()
238238
239- log .Println ("writing index file" , * indexFiles )
240- f , err := os .Create (* indexFiles )
239+ log .Println ("writing index file" , * flagIndexFiles )
240+ f , err := os .Create (* flagIndexFiles )
241241 if err != nil {
242242 log .Fatal (err )
243243 }
@@ -252,33 +252,33 @@ func runGodoc() {
252252 }
253253
254254 // Print content that would be served at the URL *urlFlag.
255- if * urlFlag != "" {
255+ if * flagUrlFlag != "" {
256256 handleURLFlag ()
257257 return
258258 }
259259
260260 if httpMode {
261261 // HTTP server mode.
262262 var handler http.Handler = http .DefaultServeMux
263- if * verbose {
263+ if * flagVerbose {
264264 log .Printf ("Go Documentation Server" )
265265 log .Printf ("version = %s" , runtime .Version ())
266- log .Printf ("address = %s" , * httpAddr )
267- log .Printf ("goroot = %s" , * goroot )
268- log .Printf ("tabwidth = %d" , * tabWidth )
266+ log .Printf ("address = %s" , * flagHttpAddr )
267+ log .Printf ("goroot = %s" , * flagGoroot )
268+ log .Printf ("tabwidth = %d" , * flagTabWidth )
269269 switch {
270- case ! * indexEnabled :
270+ case ! * flagIndexEnabled :
271271 log .Print ("search index disabled" )
272- case * maxResults > 0 :
273- log .Printf ("full text index enabled (maxresults = %d)" , * maxResults )
272+ case * flagMaxResults > 0 :
273+ log .Printf ("full text index enabled (maxresults = %d)" , * flagMaxResults )
274274 default :
275275 log .Print ("identifier search index enabled" )
276276 }
277277 handler = loggingHandler (handler )
278278 }
279279
280280 // Initialize search index.
281- if * indexEnabled {
281+ if * flagIndexEnabled {
282282 go corpus .RunIndexer ()
283283 }
284284
@@ -288,14 +288,14 @@ func runGodoc() {
288288 }
289289
290290 // Start http server.
291- if err := http .ListenAndServe (* httpAddr , handler ); err != nil {
292- log .Fatalf ("ListenAndServe %s: %v" , * httpAddr , err )
291+ if err := http .ListenAndServe (* flagHttpAddr , handler ); err != nil {
292+ log .Fatalf ("ListenAndServe %s: %v" , * flagHttpAddr , err )
293293 }
294294
295295 return
296296 }
297297
298- if * query {
298+ if * flagQuery {
299299 handleRemoteSearch ()
300300 return
301301 }
0 commit comments