golang

package
v0.0.0-...-0918f44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package golang implements Golang specific helpers for stencil templates generating Golang code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeGoMod

func MergeGoMod(leftB, rightB []byte) ([]byte, error)

MergeGoMod merges two go.mod files together. This function operates differently than a standard merge would. It is designed to conditionally merge an existing go.mod file with a templated go.mod.

## Behaviour

Noted as the "left" and "right" go.mod files (first and second values provided). They are merged with the following rules:

  • Versions from the right go.mod file will be used if the version is greater than the version in the left go.mod file or the module is not present in the left go.mod file. If a module in the left go.mod is newer than the module in the right go.mod, the left version will be used.
  • Replacements from the right go.mod file will be kept if they are not in the left go.mod file. If a replacement in the right go.mod has the same path as a replacement in the left go.mod, the left replacement will be kept. Replacements existing in the left go.mod but not in the right go.mod will be kept.
  • The go and toolchain statements from the right go.mod file will always be used over the left go.mod file.

This is heavily based on getoutreach/stencil-golang, which is licensed under the Apache-2.0 license. Link to the original as it appeared in the stencil-golang repository: https://github.com/getoutreach/stencil-golang/blob/993a3fc484e5631dd9e7004bdd304cbacac7cccd/internal/plugin/merge.go

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL