• This repository has been archived on 09/Feb/2024
  • Stars
    star
    129
  • Rank 273,095 (Top 6 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 3 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Unified text diffing in Go (copy of the internal diffing packages the officlal Go language server uses)

gotextdiff - unified text diffing in Go Go Reference Hexops logo

This is a copy of the Go text diffing packages that the official Go language server gopls uses internally to generate unified diffs.

If you've previously tried to generate unified text diffs in Go (like the ones you see in Git and on GitHub), you may have found github.com/sergi/go-diff which is a Go port of Neil Fraser's google-diff-match-patch code - however it does not support unified diffs.

This is arguably one of the best (and most maintained) unified text diffing packages in Go as of at least 2020.

(All credit goes to the Go authors, I am merely re-publishing their work so others can use it.)

Example usage

Import the packages:

import (
    "github.com/hexops/gotextdiff"
    "github.com/hexops/gotextdiff/myers"
)

Assuming you want to diff a.txt and b.txt, whose contents are stored in aString and bString then:

edits := myers.ComputeEdits(span.URIFromPath("a.txt"), aString, bString)
diff := fmt.Sprint(gotextdiff.ToUnified("a.txt", "b.txt", aString, edits))

diff will be a string like:

--- a.txt
+++ b.txt
@@ -1,13 +1,28 @@
-foo
+bar

API compatability

We will publish a new major version anytime the API changes in a backwards-incompatible way. Because the upstream is not being developed with this being a public package in mind, API breakages may occur more often than in other Go packages (but you can always continue using the old version thanks to Go modules.)

Alternatives

Contributing

We will only accept changes made upstream, please send any contributions to the upstream instead! Compared to the upstream, only import paths will be modified (to be non-internal so they are importable.) The only thing we add here is this README.

License

See https://github.com/golang/tools/blob/master/LICENSE

More Repositories

1

dockerfile

Dockerfile best-practices for writing production-worthy Docker images.
Dockerfile
4,033
star
2

mach

zig game engine & graphics toolkit
Zig
2,856
star
3

vecty

Vecty lets you build responsive and dynamic web frontends in Go using WebAssembly, competing with modern web frameworks like React & VueJS.
Go
2,774
star
4

mach-glfw

Ziggified GLFW bindings with 100% API coverage, zero-fuss installation, cross compilation, and more.
Zig
344
star
5

valast

Convert Go values to their AST
Go
303
star
6

autogold

Automatically update your Go tests
Go
272
star
7

fastfilter

fastfilter: Binary fuse & xor filters for Zig (faster and smaller than bloom filters)
Zig
245
star
8

mach-core

window+input+GPU, truly cross-platform
Zig
187
star
9

mach-gpu

mach/gpu: truly cross-platform WebGPU graphics for Zig
Zig
182
star
10

mach-gpu-dawn

Google's Dawn WebGPU implementation, cross-compiled with Zig into a single static library
Zig
144
star
11

mach-sysgpu

Highly experimental, blazingly fast, lean & mean descendant of WebGPU written in Zig
Zig
95
star
12

mach-examples

Mach engine examples
Zig
86
star
13

dawn

Fork of dawn.googlesource.com/dawn with generated code and third-party dependencies committed
C++
78
star
14

zorex

Zorex: the omnipotent regex engine
Zig
67
star
15

Azure-Kinect-Python

Python 3 bindings for the Azure Kinect SDK
Python
48
star
16

mach-dxcompiler

DXC built using Zig
C++
46
star
17

mach-freetype

Ziggified Freetype 2 bindings with zero-fuss installation, cross compilation, and more.
Zig
44
star
18

mach-glfw-vulkan-example

mach-glfw Vulkan example
Zig
37
star
19

zgo

Go + Zig = ๐Ÿ’• | Zig and Go are best friends
Go
37
star
20

mach-glfw-opengl-example

Example for using mach-glfw with zig-opengl
Zig
35
star
21

mach-ecs

Entity Component System from first-principles designed for Zig
34
star
22

mach-sysaudio

cross-platform low-level audio IO in Zig
Zig
29
star
23

mach-sysjs

enables Zig/WASM to speak to JavaScript
Zig
28
star
24

awesome-zig-gamedev

Comprehensive collection of maintained zig gamedev projects & libraries
17
star
25

xcode-frameworks

XCode frameworks packaged for the Zig build system
C
17
star
26

mach-core-starter-project

The result of running through https://machengine.org/core/getting-started
Zig
16
star
27

mach-gamemode

mach-gamemode: make your Linux games go brrr
14
star
28

cmder

Lightweight Go pattern for writing CLIs with subcommands
Go
12
star
29

harfbuzz

A fork of harfbuzz packaged for the Zig build system
C++
12
star
30

pgtrgm_emperical_measurements

Emperical measurements of pg_trgm performance at scale
Shell
11
star
31

brotli

A fork of brotli packaged for the Zig build system
C
11
star
32

zigmonthly.org

Curated Zig news brought to you by @slimsag each month
SCSS
11
star
33

mach-system-sdk

DirectX 12 headers for MinGW/Zig, cross-compile DX12/Metal/etc with Zig, etc.
10
star
34

glfw

A fork of GLFW packaged for the Zig build system
C
10
star
35

sdk-macos-11.3

Also see https://github.com/hexops/sdk-macos-12.0
C
9
star
36

libmach

C API to Mach core and Mach engine
C
9
star
37

vulkan-zig-generated

Snektron/vulkan-zig, but generated and comitted for use as a package manager dependency
Zig
8
star
38

wrench

[bot] ๐Ÿต Wrench here! Let's fix this! ๐Ÿ”ง
Go
8
star
39

freetype

A fork of freetype packaged for the Zig build system
C
8
star
40

machengine.org

machengine.org website, documentation, etc.
SCSS
8
star
41

mach-editor

Mach CLI and graphical editor
Zig
8
star
42

devlog

Hexops devlog
SCSS
7
star
43

vulkan-headers

A fork of vulkan-headers packaged for the Zig build system
C++
7
star
44

mach-model3d

compact, featureful model format & alternative to glTF
C
7
star
45

font-assets

Various fonts packaged for the Zig build system
Zig
7
star
46

sinter

Sinter text search engine
Zig
6
star
47

mach-opus

Opus audio decoding and encoding for Zig via the battle-hardened xiph.org libopus
Zig
6
star
48

basisu

A fork of basisu packaged for the Zig build system
C
6
star
49

sdk-macos-12.0

macOS 12.0 Monterey SDK for Mach engine
C
6
star
50

mach-basisu

basis universal (supercompressed textures) for Zig
Zig
6
star
51

mach-objc

Generated Objective-C bindings for Zig
Zig
5
star
52

linux-audio-headers

linux-audio-headers packaged for the Zig build system
C
5
star
53

mach-flac

FLAC audio decoding and encoding for Zig via the battle-hardened xiph.org libflac
Zig
5
star
54

x11-headers

x11-headers packaged for the Zig build system
C
5
star
55

mach-rs

Rust bindings for Mach
5
star
56

sycl24

Software You Can Love 2024 workshop
Zig
5
star
57

direct3d-headers

Enables using the latest Direct3D headers and libraries with Zig
C
4
star
58

ControlCursor

A C# library for getting and setting global cursor position.
C#
4
star
59

hexi-old

Hexi: Game Engine & Graphics Toolkit
Rust
4
star
60

wayland-headers

wayland-headers packaged for the Zig build system
C
4
star
61

spirv-cross

A fork of spirv-cross packaged for the Zig build system
C++
3
star
62

spirv-tools

A fork of spirv-tools packaged for the Zig build system
C++
3
star
63

hexops.com

hexops.com website
SCSS
3
star
64

opengl-headers

opengl-headers packaged for the Zig build system
C
3
star
65

soundio

libsoundio upstream sources used by Mach engine
C
3
star
66

sdk-macos-13.3

macOS 13.3 Ventura SDK for Mach engine
C
3
star
67

sdk-linux-x86_64

Linux x86_64 SDK for Mach engine
C++
3
star
68

mach-ggml

Zig
3
star
69

lordofzero

Shell
3
star
70

opusfile

A fork of opusfile packaged for the Zig build system
C
2
star
71

sdk-linux-aarch64

Linux aarch64 SDK for Mach engine
C++
2
star
72

ogg

A fork of ogg packaged for the Zig build system
C
2
star
73

sdk-windows-x86_64

Windows x86_64 SDK for Mach engine
C
2
star
74

mach-objc-generator

Zig Objective-C binding generator
Zig
2
star
75

ztemplate

Hexops Zig template repository
Zig
1
star
76

tridex-assets

Static contents / assets for Tridex
1
star
77

opus

A fork of opus packaged for the Zig build system
C
1
star
78

opusenc

A fork of libopusenc packaged for the Zig build system
C
1
star
79

directx-headers

A fork of DirectX-Headers, packaged with the Zig build system and compatible with cross-compilation
C
1
star
80

flac

A fork of flac packaged for the Zig build system
C
1
star
81

mach-example-assets

Example assets for Mach engine
1
star
82

stackptr

1
star