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

bash
gox run [options]
OptionDescription
-devIt activates the way of development.
-host Overwrite the HTTP host.
- port Overwrite the HTTP port.

The command does not accept positional arguments.


Execution

bash
gox run

GOX carries out the following operations:

  1. It detects and uses the root of the project.
  2. It guarantees the availability of the Go toolchain.
  3. Comply the configuration of app/config.gox and their modules.
  4. Create the runtime with the resulting configuration.
  5. Clean the temporary configuration devices.
  6. Run the start hole.
  7. Start hearing requests.

The server remains active until the process is stopped or ended by an error.


dev

bash
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:

bash
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:

bash
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:

bash
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 -host and -port for 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.

Next step

Continue with Dependencies to add, delete, install and synchronize the modules used by the project.

Dependencies