mirror of
https://github.com/golang/go
synced 2024-11-22 01:44:40 -07:00
godoc: basic setup for running godoc on local app engine emulator
R=rsc CC=golang-dev https://golang.org/cl/4559058
This commit is contained in:
parent
ce2701b2b0
commit
59a190589a
22
misc/godoc/README
Normal file
22
misc/godoc/README
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Instructions to get an initial godoc running on a local app engine emulator
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
To run godoc under the app engine emulator, create a ("goroot") godoc
|
||||||
|
directory that contains the app.yaml file, the doc and lib directories
|
||||||
|
from the Go distribution, as well as a godoc directory with the godoc
|
||||||
|
sources from src/cmd/godoc. In the godoc source directory, replace
|
||||||
|
main.go with init.go. The directory structure should look as follows:
|
||||||
|
|
||||||
|
godoc // "goroot" directory
|
||||||
|
app.yaml // app engine control file
|
||||||
|
doc // goroot/doc directory
|
||||||
|
favicon.ico
|
||||||
|
godoc // contains godoc sources
|
||||||
|
godoc.go // unchanged godoc file
|
||||||
|
init.go // this file instead of godoc/main.go
|
||||||
|
... // remaining godoc files
|
||||||
|
lib // goroot/lib directory
|
||||||
|
|
||||||
|
Run app engine emulator locally: dev_appserver.py -a <hostname> godoc
|
||||||
|
where godoc is the top-level "goroot" directory. The godoc home page
|
||||||
|
is then served at: <hostname>:8080 .
|
12
misc/godoc/app.yaml
Normal file
12
misc/godoc/app.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style
|
||||||
|
# license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
application: godoc
|
||||||
|
version: 1
|
||||||
|
runtime: go
|
||||||
|
api_version: 1
|
||||||
|
|
||||||
|
handlers:
|
||||||
|
- url: /.*
|
||||||
|
script: _go_app
|
35
misc/godoc/init.go
Normal file
35
misc/godoc/init.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// This file replaces main.go when running godoc under the app engine emulator.
|
||||||
|
// See the README file for instructions.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"http"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
func serveError(w http.ResponseWriter, r *http.Request, relpath string, err os.Error) {
|
||||||
|
contents := applyTemplate(errorHTML, "errorHTML", err) // err may contain an absolute path!
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
servePage(w, "File "+relpath, "", "", contents)
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// set goroot
|
||||||
|
cwd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("cwd: %s", err)
|
||||||
|
}
|
||||||
|
log.Printf("cwd = %s", cwd)
|
||||||
|
*goroot = filepath.Clean(cwd)
|
||||||
|
|
||||||
|
initHandlers()
|
||||||
|
readTemplates()
|
||||||
|
registerPublicHandlers(http.DefaultServeMux)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user