Giter Site home page Giter Site logo

simpleanalyzer's Introduction

Simple Analyzer

Simple Analyzer is an example analyzer for the Gourmet project. It is meant to be analagous to a "Hello, World!" example program often found in software projects.

Usage

To use Simple Analyzer, there are two ways:

  1. Add the Github URL to your Gourmet config.yml file. Gourmet's example config file demonstrates how to do this.
  2. Pass the URL as command-line option like this: gourmet -a github.com/gourmetproject/simple_analyzer

How It Works

Gourmet Analyzers are Go Plugins that implement the Gourmet Analyzer interface. In order to create a Gourmet Analyzer, your repository must:

  1. Contain a main.go file at the root of the repository

  2. The main.go file must be part in the main package. Analyzers are not standard Go libraries, but are instead Go plugins. Read the Go plugin docs for more information.

  3. The code in main.go must implement the gourmet.Analyzer interface. Simple Analyzer does this by creating a new public type called SimpleAnalyzer, which is just an empty struct. It then declares two methods, Filter and Analyze, with SimpleAnalyzer as the pointer receiver. These two methods' signatures implement the gourmet.Analyzer interface.

    NOTE: If you are not familiar with methods and pointer receivers, check this out.

    NOTE: Go enforces public/private visibility through the name of the identifier itself. If the identifier starts in a capital letter, it is exported (public). If it starts with a lowercase letter, it is private. You can read more here.

  4. The code in main.go must also implement the gourmet.Result interface. Simple Analyzer does this by creating a new public type called SimpleResult, which is just an integer. It then declares the Key method with SimpleResult as the value receiver (not pointer receiver, since we aren't modifying the underlying SimpleResult object in the Key method).

And that's it! We now have a simple Gourmet Analyzer.

Contact Us

Slack icon

Support Us

Patreon

simpleanalyzer's People

Contributors

spitfire55 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.