patch

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: MIT Imports: 9 Imported by: 0

README

Syntax-aware Patch

This package provides an intuitive way to patch the go code.

The purpose is to power xgo's patching mechanism.

See #169.

Examples

You can find more examples in the testdata directory.

The following example is taken from ./testdata/hello_world/.

original.go:

package main

import "fmt"

func main() {
	fmt.Printf("hello world\n")
}

original.go.patch:

package main

func main(){
    //append <id> fmt.Printf("the world is patched\n")
    fmt.Printf("hello world\n")
}

result.go:

package main

import "fmt"

func main() {
	fmt.Printf("hello world\n")
	fmt.Printf("the world is patched\n")
}

Documentation

Index

Constants

View Source
const DOUBLE_SLASH = "//"

Variables

This section is empty.

Functions

func PatchFile

func PatchFile(srcFile string, patchFile string) (string, error)

Types

type PatchContent

type PatchContent struct {
	Prepend *PatchLines
	Append  *PatchLines
	Replace *PatchLines
}

type PatchLines added in v1.0.48

type PatchLines struct {
	ID    string
	Lines []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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