Files
vercel/packages/now-cli/test/dev/fixtures/go/api/another.go
Nathan Rajlich 04bea1e3cd [go] Implement startDevServer() function (#4662)
Due to Go's peculiar package importing structure, there's unfortunately no way to _directly_ invoke a Go serverless file, so the approach for this `startDevServer()` function is:

 * Create a temp directory in `.vercel/cache`
 * Run the `analyze` Go program on the entrypoint file to determine the `functionName`
 * Copy the entrypoint file into the temp directory, while modifying it to use `package main`
 * Copy the `dev-server.go` file into the temp directory, replacing the placeholder function name with the `functionName` retrieved from the analysis step from before
 * Execute `go run $tmp_dir` to spawn the Go HTTP server on an ephemeral port
 * Return the Go process id and port number for `vercel dev` to proxy to
 * After the Go process has exited, delete the temp directory
2020-06-24 19:50:00 +00:00

11 lines
145 B
Go

package another
import (
"fmt"
"net/http"
)
func Another(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "This is another page")
}