Giter VIP home page Giter VIP logo

safechange's Introduction

Description

This tool returns exitcode 0 if two Go files has equivalent source code (which is expected to have the same machine code after compilation), and returns exitcode 1 if not.

This is supposed to be used to check if a change after a code review requires an additional review. For example:

  • Often in review one may accept a change and propose to optionally add a comment. In this case the author of the change has to choose between adding a comment (which leads to resetting the code review approval) or deliver the code as is. To avoid this dilemma this tool allows validating if the code change is safe (for example a change in comments).

Install

go get github.com/xaionaro-go/safechange/cmd/safechange

Run

safechange <file1> <file2>

Example

/tmp/1.go:

package pkg
import (
	"fmt"

	"io"
)

import "io/ioutil"

import "errors"

func main() {
	// some comment
}

/tmp/2.go:

package pkg
import (
	"errors"
	"fmt"
	"io/ioutil"
	"io"
)

func main() {
}

/tmp/3.go:

package pkg
import (
	"errors"
	"fmt"
	"io/ioutil"
	"io"
)

func main() {
	fmt.Println("hello!")
}

Files 1.go and 2.go are equivalent:

$ safechange /tmp/1.go /tmp/2.go
$ echo $?
0

Files 1.go and 3.go are not equivalent (because 3.go has fmt.Println, while 1.go hasn't):

$ safechange /tmp/1.go /tmp/3.go
$ echo $?
1

safechange's People

Contributors

xaionaro avatar

Stargazers

 avatar

Watchers

 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.