mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-06 04:22:01 +00:00
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
11 lines
145 B
Go
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")
|
|
}
|