LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package main | 5 package main |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "encoding/json" | 9 "encoding/json" |
10 "flag" | 10 "flag" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 goroot = flag.String("goroot", runtime.GOROOT(), "Go root directory") | 60 goroot = flag.String("goroot", runtime.GOROOT(), "Go root directory") |
61 testDir = flag.String("testdir", "", "Go root subdirectory - for testing
only (faster startups)") | 61 testDir = flag.String("testdir", "", "Go root subdirectory - for testing
only (faster startups)") |
62 | 62 |
63 // layout control | 63 // layout control |
64 tabwidth = flag.Int("tabwidth", 4, "tab width") | 64 tabwidth = flag.Int("tabwidth", 4, "tab width") |
65 showTimestamps = flag.Bool("timestamps", false, "show timestamps with di
rectory listings") | 65 showTimestamps = flag.Bool("timestamps", false, "show timestamps with di
rectory listings") |
66 templateDir = flag.String("templates", "", "directory containing alte
rnate template files") | 66 templateDir = flag.String("templates", "", "directory containing alte
rnate template files") |
67 showPlayground = flag.Bool("play", false, "enable playground in web inte
rface") | 67 showPlayground = flag.Bool("play", false, "enable playground in web inte
rface") |
68 showExamples = flag.Bool("ex", false, "show examples in command line m
ode") | 68 showExamples = flag.Bool("ex", false, "show examples in command line m
ode") |
69 declLinks = flag.Bool("links", true, "link identifiers to their dec
larations") | 69 declLinks = flag.Bool("links", true, "link identifiers to their dec
larations") |
| 70 noCmd = flag.Bool("nocmd", false, "treat main packages as regul
ar packages, rather than commands") |
70 | 71 |
71 // search index | 72 // search index |
72 indexEnabled = flag.Bool("index", false, "enable search index") | 73 indexEnabled = flag.Bool("index", false, "enable search index") |
73 indexFiles = flag.String("index_files", "", "glob pattern specifying i
ndex files;"+ | 74 indexFiles = flag.String("index_files", "", "glob pattern specifying i
ndex files;"+ |
74 "if not empty, the index is read from these files in sorted orde
r") | 75 "if not empty, the index is read from these files in sorted orde
r") |
75 maxResults = flag.Int("maxresults", 10000, "maximum number of full te
xt search results shown") | 76 maxResults = flag.Int("maxresults", 10000, "maximum number of full te
xt search results shown") |
76 indexThrottle = flag.Float64("index_throttle", 0.75, "index throttle val
ue; 0.0 = no time allocated, 1.0 = full throttle") | 77 indexThrottle = flag.Float64("index_throttle", 0.75, "index throttle val
ue; 0.0 = no time allocated, 1.0 = full throttle") |
77 | 78 |
78 // file system information | 79 // file system information |
79 fsTree RWValue // *Directory tree of packages, updated with each sy
nc (but sync code is removed now) | 80 fsTree RWValue // *Directory tree of packages, updated with each sy
nc (but sync code is removed now) |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 | 1156 |
1156 } else { | 1157 } else { |
1157 // show source code | 1158 // show source code |
1158 // TODO(gri) Consider eliminating export filtering in th
is mode, | 1159 // TODO(gri) Consider eliminating export filtering in th
is mode, |
1159 // or perhaps eliminating the mode altogether. | 1160 // or perhaps eliminating the mode altogether. |
1160 if mode&noFiltering == 0 { | 1161 if mode&noFiltering == 0 { |
1161 packageExports(fset, pkg) | 1162 packageExports(fset, pkg) |
1162 } | 1163 } |
1163 info.PAst = ast.MergePackageFiles(pkg, 0) | 1164 info.PAst = ast.MergePackageFiles(pkg, 0) |
1164 } | 1165 } |
1165 » » info.IsMain = pkgname == "main" | 1166 » » info.IsMain = !*noCmd && pkgname == "main" |
1166 } | 1167 } |
1167 | 1168 |
1168 // get directory information, if any | 1169 // get directory information, if any |
1169 var dir *Directory | 1170 var dir *Directory |
1170 var timestamp time.Time | 1171 var timestamp time.Time |
1171 if tree, ts := fsTree.get(); tree != nil && tree.(*Directory) != nil { | 1172 if tree, ts := fsTree.get(); tree != nil && tree.(*Directory) != nil { |
1172 // directory tree is present; lookup respective directory | 1173 // directory tree is present; lookup respective directory |
1173 // (may still fail if the file system was updated and the | 1174 // (may still fail if the file system was updated and the |
1174 // new directory tree has not yet been computed) | 1175 // new directory tree has not yet been computed) |
1175 dir = tree.(*Directory).lookup(abspath) | 1176 dir = tree.(*Directory).lookup(abspath) |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 updateIndex() | 1578 updateIndex() |
1578 } | 1579 } |
1579 delay := 60 * time.Second // by default, try every 60s | 1580 delay := 60 * time.Second // by default, try every 60s |
1580 if *testDir != "" { | 1581 if *testDir != "" { |
1581 // in test mode, try once a second for fast startup | 1582 // in test mode, try once a second for fast startup |
1582 delay = 1 * time.Second | 1583 delay = 1 * time.Second |
1583 } | 1584 } |
1584 time.Sleep(delay) | 1585 time.Sleep(delay) |
1585 } | 1586 } |
1586 } | 1587 } |
LEFT | RIGHT |