Ich habe versucht, eine bestimmte lokale Go-Datei als Dokumentationswebseite zu liefern, war aber nicht dazu in der Lage.Wie Server einfache Dokumentation für Go-Programme mit Godoc als Webseite Server?
Die official godoc documentation sagt:
Mit dem -http Flag (das heißt der godoc Befehl), es läuft als Web-Server und stellt die Dokumentation als Webseite.
user_me$ godoc -http=:6060
Dies macht etwas Ähnliches wie unterwegs Seite erstellen, aber es ist nicht die bestimmte Datei machen, die ich machen möchte. Also versuchte ich den Namen der Datei zur Verfügung gestellt ich wollte:
user_me$ godoc -http=:6000 hello.go
jedoch antwortet sie nur mit:
usage: godoc package [name ...]
godoc -http=:6060
-ex=false: show examples in command line mode
-goroot="/usr/local/go": Go root directory
-html=false: print HTML in command-line mode
-http="": HTTP service address (e.g., ':6060')
-httptest.serve="": if non-empty, httptest.NewServer serves on this address and blocks
-index=false: enable search index
-index_files="": glob pattern specifying index files;if not empty, the index is read from these files in sorted order
-index_throttle=0.75: index throttle value; 0.0 = no time allocated, 1.0 = full throttle
-links=true: link identifiers to their declarations
-maxresults=10000: maximum number of full text search results shown
-notes="BUG": regular expression matching note markers to show
-play=false: enable playground in web interface
-q=false: arguments are considered search queries
-server="": webserver address for command line searches
-src=false: print (exported) source in command-line mode
-tabwidth=4: tab width
-templates="": directory containing alternate template files
-timestamps=false: show timestamps with directory listings
-url="": print HTML for named URL
-v=false: verbose mode
-write_index=false: write index to a file; the file name must be specified with -index_files
-zip="": zip file providing the file system to serve; disabled if empty
ich auch versucht:
user_me$ godoc -url="localhost:8080" hello.go
aber es hat nicht funktioniert .
Ich habe auch versucht:
godoc -server=localhost:8080 hello.go
aber es antwortete mit:
2014/07/01 10:45:56 open /usr/local/go/src/pkg/hello.go: no such file or directory
ich auch nur versucht, die Erzeugung der HTML-Sache selbst:
godoc -html hello.go > hello.html
gleichen Fehler wie oben.
Ich habe auch versucht (da es beschwerte sich, dass es keine Datei im PKG dir war):
godoc -html -goroo=$GOPATH hello.go > hello.html
Am Ende gab ich auf. Ich weiß nicht, wie diese Godoc-Sache funktioniert. Ich habe das hello.go-Programm installiert, so dass ich etwas in der pkg-Datei im Arbeitsbereich hatte. Wie generieren Sie eine Webseite mit Ihrer Dokumentation für Ihren Code?
als ich godoc 'hey/world' machte, bekam ich nur' COMMAND DOKUMENTATION' und das ist es, sonst nichts.Wenn Sie godoc starten und auf diese Seite gehen, sehe ich den Namen des Repos, aber es zeigt nicht die Dokumentation für mein einziges hello.go Programm. Warum das? – Pinocchio
muss ich noch mal installieren oder etwas installieren? Das hat auch nicht wirklich funktioniert ... – Pinocchio
Vergessen zu erwähnen: godoc funktioniert anders, wenn das Ziel eine ausführbare Datei ist (d. H. 'Package main'); In diesem Fall wird nur der Kommentar auf Paketebene angezeigt. Ein Beispiel finden Sie unter http://golang.org/src/cmd/gofmt/doc.go – lnmx