Step 3: View code and build
With the generated code we can view locally or on your VCS.
Go ahead and check out that the repository has been created.
Lets check the code locally and see if runs. Open a command line terminal at location course502/src and execute the following commands.
go mod tidy
go run ./...
The go mod tidy is recommended to tidy up and manage the required modules.
You should now have a HTTP Server started. This has been started with inbuilt defaults.
If you access the web server locally with http://localhost:8080 you will get an error message, such as below
{
"message": "no matching operation was found",
"resolution": "Please check the Operation name and resource and correct to a valid name. Reference the Open API specification for valid names",
"status": "DM00400"
}
If you access it locally with http://localhost:8080/index.html up will see also see an error. Let’s make the HTTP server use the default static page. To do this stop the server with Ctrl+c
Now create a new folder named config in the root directory of course502 and start the web server again. The presence of an empty config folder will be an indicator to the code to create a default configuration file into that location.
If you now access it locally with http://localhost:8080/index.html up will see a basic HTML page with a link to the base OpenAPI specification. Please have a review of the basic OpenAPI definition template that was attached to this project.
Feel free to explore the source code.
Errors
If you have any errors in building you will need review the error messages. Some possible reasons are:
- Not the correct level of Golang
- Inability to find/fetch the Golang modules