Serve & Watch
serve runs Go applications as servers. In development it watches files and restarts the process; in production it runs the built binary.
putnami serve .
putnami serve . --port 8080Entrypoint detection
When no entrypoint is provided, the extension resolves a runnable package in this order:
- root
main.go - a single
cmd/<name>directory - preferred command directories such as
cmd/serve,cmd/server,cmd/<project-name>, orcmd/api - an explicit error telling you to pass
--entrypoint
Options
| Option | Use |
|---|---|
--watch <boolean> |
Enable development watch mode |
--port <number> |
Set the PORT environment variable |
--killPort |
Kill the existing process using the port before starting |
--args <string> |
Pass arguments to the Go process |
Watch behavior
Watch mode monitors Go files in the project and dependency projects. It ignores vendor directories, test files, and generated directories that should not restart the server.