Documentation
¶
Overview ¶
Copyright 2025 HAProxy Technologies LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2025 HAProxy Technologies LLC ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteDiffFiles ¶
WriteDiffFiles generates Go files containing Diff methods based on the provided code generation context (`ctx`). It organizes generated code by output file and package.
Parameters:
- dir: Base directory where files will be written
- file: Initial target file path (may be overridden based on type and package)
- files: Map of file paths to a map of code sections ("Package", "Imports", "Diff")
- ctx: Code generation context containing metadata and generated implementations
Behavior:
- Skips generation if Diff function name or implementation is empty, or if there was an error.
- For struct types or defined types, generates a dedicated Go file with the full Diff function.
- For other cases, appends the Diff implementation to an existing entry in the `files` map.
- Recursively processes any sub-contexts to handle nested or related types.
func WriteEqualFiles ¶
WriteEqualFiles generates Go source code for Equal functions based on the given context and writes them into an in-memory map of files.
Parameters:
- dir: base directory where files should be placed.
- file: the current target filename (may be overridden based on context).
- files: an in-memory structure mapping filenames to a map of code sections (Package, Imports, Equal, etc.).
- ctx: a data.Ctx object containing type metadata and the Equal implementation.
Behavior:
- If the context has no Equal function name or implementation, nothing is written.
- If the type is a struct or a defined type, a dedicated "_equal_generated.go" file is created for that type, including package declaration, imports, and the Equal method body.
- If the type is not a struct/defined type, the Equal implementation is appended to the existing file entry.
- This function is recursive: it processes all sub-contexts in ctx.SubCtxs.
Types ¶
This section is empty.