Documentation
¶
Overview ¶
Copyright (c) 2023-2026 thorsphere. All Rights Reserved. Use is governed with GNU Affero General Public License v3.0 that can be found in the LICENSE file.
Package tserrgen provides automated Go code generation for the tserr package. It reads error definitions from a JSON configuration file and generates the corresponding error types, API functions, and test functions.
The main component is:
- Generate: The primary entry point that orchestrates the entire code generation process. It reads a JSON configuration file, parses the error definitions, and invokes the appropriate generators for messages, API functions, and tests.
The JSON configuration file defines errors with their names, comments, HTTP status codes, message templates, and parameter specifications. The generator creates type-safe, testable error functions that integrate seamlessly with the tserr error handling package.
The package leverages lpcode for programmatic code generation, tsfio for file operations, and tserr for consistent error handling throughout the generation process.
Copyright (c) 2023-2026 thorsphere. All Rights Reserved. Use is governed with GNU Affero General Public License v3.0 that can be found in the LICENSE file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate generates Go code for the tserr package based on the error definitions provided in the JSON file specified by fn. It reads the JSON file, unmarshals it into a tserrconfig struct, and then generates the necessary Go code for error messages and API functions. If any error occurs during this process, it returns an error with details about the operation that failed.
Types ¶
This section is empty.