Giter VIP home page Giter VIP logo

godiff's Introduction

GoDiff

Simple tool to track changes ( modification and insertion ) between to versions of a content.

Usage

Initialization of the first version of the file

	f1, e := readFile("./testdata/v1.txt")
	origin := IniDoc(f1, "version_Id_1")

Once Initialized and second version can be compared with the origin

	f2, e := readFile("./testdata/v2.txt")
	diff, e := ProcessDiff(origin, f2, "version_Id_2")

The generated diff can be dumped into a file

	e = diff.dump("./", "my_diff.txt")

This file will look like:

1|name: lagoon                                                             |from: version_Id_1
2|qualifier: dev2                                                          |from: version_Id_1
3|ekara:                                                                   |from: version_Id_1
4|  distribution:                                                          |from: version_Id_1
5|    repository: ""                                                       |from: version_Id_1
6|    ref: ""                                                              |from: version_Id_1
7|  components:                                                            |from: version_Id_2
8|    distrib:                                                             |from: version_Id_2
9|      repository: https://github.com/blablabla                           |from: version_Id_2
10|      ref: my-addon                                                     |from: version_Id_1
11|      auth:                                                             |from: version_Id_1
12|        method: basic                                                   |from: version_Id_2
13|        password: mypassword                                            |from: version_Id_1
14|        user: myuwer                                                    |from: version_Id_1
15|    helios:                                                             |from: version_Id_1
16|      repository: dummy/openstack-provider                              |from: version_Id_2
17|      ref: fix-modules                                                  |from: version_Id_2
18|    prometheus:                                                         |from: version_Id_2

Columns content :

  • 1 the line number
  • 2 the line content
  • 3 the line version

The generated diff can also be dumped into the console

	e = diff.dumpOut()

This is an example of the console dump poduced by the test TestDumpNeruda

The schown dump is the result of the comparison of /testdata/v1.txt with /testdata/v2.txt and finally with /testdata/v3.txt

	f1, _ := readFile("./testdata/v1.txt")
	f2, _ := readFile("./testdata/v2.txt")
	f3, _ := readFile("./testdata/v3.txt")

	origin := IniDoc(f1, "v1.txt")
	diff, _ := ProcessDiff(origin, f2, "v2.txt")
	diff, _ = ProcessDiff(diff, f3, "v3.txt")
	diff.dumpOut()

Dump on the console :

neruda dump

godiff's People

Contributors

nirekin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.