Coder Social home page Coder Social logo

go-gitguardian's Introduction

go-gitguardian - GitGuardian API Client

Go API client library for the GitGuardian API

How to use this library

Each category of endpoints has it own package.

So if you want to use the scanning endpoint, you import the scan package like this:

package main

import (
	"fmt"
	"log"

	"github.com/Gaardsholt/go-gitguardian/client"
	"github.com/Gaardsholt/go-gitguardian/scan"
)

func main() {

	c, err := scan.NewClient(client.WithApiKey("<YOUR_API_KEY>"))
	if err != nil {
		log.Fatal(err)
	}

	resp, err := c.ContentScan(scan.ContentScanPayload{
		Filename: "my_file.py",
		Document: `import urllib.request
    url = 'http://jen_barber:[email protected]/isreal.json'
    response = urllib.request.urlopen(url)
    consume(response.read())`,
	})
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%+v\n", resp.Result)
}

You can set the API key by either using the client.WithApiKey function or by setting the environment varible GITGUARDIAN_API_KEY.

If you are running a self hosted version of GitGuardian you can also set the server address by either using the client.WithServer function or by setting the environment varible GITGUARDIAN_SERVER.

Stuff missing from this library

  • Better logging
  • Do a checkup on the error handling
  • Add tests
  • Properly more...

go-gitguardian's People

Contributors

gaardsholt avatar francois2metz avatar dependabot-circleci[bot] 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.