run
gox run compiles the project configuration, creates the GOX runtime and starts the HTTP server.
The command detects the project root from the current directory and uses its configuration to start the application.
It can be used immediately after creating an application with gox createproject.
Use
gox run [options] | Option | Description |
|---|---|
| -dev | It activates the way of development. |
| -host | Overwrite the HTTP host. |
| - port | Overwrite the HTTP port. |
The command does not accept positional arguments.
Execution
gox run GOX carries out the following operations:
- It detects and uses the root of the project.
- It guarantees the availability of the Go toolchain.
- Comply the configuration of
app/config.goxand their modules. - Create the runtime with the resulting configuration.
- Clean the temporary configuration devices.
- Run the start hole.
- Start hearing requests.
The server remains active until the process is stopped or ended by an error.
dev
gox run -dev -dev overwrite config.Dev.Enabled with true for the current and active execution of the runtime development functions.
In development mode, all responses are delivered with the expired cache. This forces the client to obtain or revalidate each resource, including static files, and prevents a stored version from hiding the changes made during development.
host
-host temporarily replace the host defined in the HTTP configuration:
gox run -host 0.0.0.0
gox run -host localhost Valid IP addresses and host names are allowed. Empty values, spaces, bars, empty labels or labels that start or end with -.
-host You can show up once.
port
-port temporarily replace the HTTP port:
gox run -port 8080 The value must be found between 1 and 65535. -port You can show up once.
Temporary overrides
-dev, -host and -port apply only to the runtime initiated by the command. They do not modify the project files.
It is possible to combine them:
gox run -host 0.0.0.0 -port 8080 Startup errors
The command ends if you do not find a project, the compilation fails, the configuration is invalid, the port cannot be used, or the start hook returns an error.
When the start hook fails, GOX respects the controlled runtime output without printing a second error message from the CLI router.
Best practices
- It declares the persistent behavior in the project configuration.
- Use
-hostand-portfor temporary execution changes. - Do not repeat options within the same command.
- Check the availability of the port before starting several instances.
- Check the compilation errors before investigating the runtime.