Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
3cd8f27d
Commit
3cd8f27d
authored
Jul 02, 2011
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
godoc: search GOPATH for documentation
R=rsc, mattn.jp CC=golang-dev
https://golang.org/cl/4627065
parent
72a73198
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
8 deletions
+21
-8
godoc.go
src/cmd/godoc/godoc.go
+10
-1
main.go
src/cmd/godoc/main.go
+5
-1
mapping.go
src/cmd/godoc/mapping.go
+6
-6
No files found.
src/cmd/godoc/godoc.go
View file @
3cd8f27d
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"flag"
"flag"
"fmt"
"fmt"
"go/ast"
"go/ast"
"go/build"
"go/doc"
"go/doc"
"go/printer"
"go/printer"
"go/token"
"go/token"
...
@@ -83,7 +84,15 @@ var (
...
@@ -83,7 +84,15 @@ var (
func
initHandlers
()
{
func
initHandlers
()
{
fsMap
.
Init
(
*
pkgPath
)
paths
:=
filepath
.
SplitList
(
*
pkgPath
)
for
_
,
t
:=
range
build
.
Path
{
if
t
.
Goroot
{
continue
}
paths
=
append
(
paths
,
t
.
SrcDir
())
}
fsMap
.
Init
(
paths
)
fileServer
=
http
.
FileServer
(
http
.
Dir
(
*
goroot
))
fileServer
=
http
.
FileServer
(
http
.
Dir
(
*
goroot
))
cmdHandler
=
httpHandler
{
"/cmd/"
,
filepath
.
Join
(
*
goroot
,
"src"
,
"cmd"
),
false
}
cmdHandler
=
httpHandler
{
"/cmd/"
,
filepath
.
Join
(
*
goroot
,
"src"
,
"cmd"
),
false
}
pkgHandler
=
httpHandler
{
"/pkg/"
,
filepath
.
Join
(
*
goroot
,
"src"
,
"pkg"
),
true
}
pkgHandler
=
httpHandler
{
"/pkg/"
,
filepath
.
Join
(
*
goroot
,
"src"
,
"pkg"
),
true
}
...
...
src/cmd/godoc/main.go
View file @
3cd8f27d
...
@@ -31,6 +31,7 @@ import (
...
@@ -31,6 +31,7 @@ import (
"flag"
"flag"
"fmt"
"fmt"
"go/ast"
"go/ast"
"go/build"
"http"
"http"
_
"http/pprof"
// to serve /debug/pprof/*
_
"http/pprof"
// to serve /debug/pprof/*
"io"
"io"
...
@@ -332,7 +333,10 @@ func main() {
...
@@ -332,7 +333,10 @@ func main() {
}
}
relpath
:=
path
relpath
:=
path
abspath
:=
path
abspath
:=
path
if
!
filepath
.
IsAbs
(
path
)
{
if
t
,
pkg
,
err
:=
build
.
FindTree
(
path
);
err
==
nil
{
relpath
=
pkg
abspath
=
filepath
.
Join
(
t
.
SrcDir
(),
pkg
)
}
else
if
!
filepath
.
IsAbs
(
path
)
{
abspath
=
absolutePath
(
path
,
pkgHandler
.
fsRoot
)
abspath
=
absolutePath
(
path
,
pkgHandler
.
fsRoot
)
}
else
{
}
else
{
relpath
=
relativeURL
(
path
)
relpath
=
relativeURL
(
path
)
...
...
src/cmd/godoc/mapping.go
View file @
3cd8f27d
...
@@ -59,10 +59,10 @@ type mapping struct {
...
@@ -59,10 +59,10 @@ type mapping struct {
}
}
// Init initializes the Mapping from a list of paths
separated by
// Init initializes the Mapping from a list of paths
.
//
filepath.ListSeparator. Empty paths are ignored; relative paths
//
Empty paths are ignored; relative paths are assumed to be relative to
//
are assumed to be relative to the current working directory and
//
the current working directory and converted to absolute paths.
//
converted to absolute paths.
For each path of the form:
// For each path of the form:
//
//
// dirname/localname
// dirname/localname
//
//
...
@@ -80,8 +80,8 @@ type mapping struct {
...
@@ -80,8 +80,8 @@ type mapping struct {
// user -> /home/user
// user -> /home/user
// public -> /home/build/public
// public -> /home/build/public
//
//
func
(
m
*
Mapping
)
Init
(
paths
string
)
{
func
(
m
*
Mapping
)
Init
(
paths
[]
string
)
{
pathlist
:=
canonicalizePaths
(
filepath
.
SplitList
(
paths
)
,
nil
)
pathlist
:=
canonicalizePaths
(
paths
,
nil
)
list
:=
make
([]
mapping
,
len
(
pathlist
))
list
:=
make
([]
mapping
,
len
(
pathlist
))
// create mapping list
// create mapping list
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment