Giter VIP home page Giter VIP logo

kargo's Introduction

LogoKargo

GoDoc Build Status Coverage Status

Kargo determines carrier of the tracking number barcode and checks if that tracking number barcode is valid by matching the format and calculating checksum validity. Feel free to create pull requests and issues.

Package supports

  • UPS
  • FedEx Express
  • FedEx Ground "96"
  • USPS IMpb
  • USPS UPU S10
  • USPS 20

But more on the way

  • DHL

Install

go get github.com/unicod3/kargo

Usage and Examples

Kargo's usage is pretty straight forward, supply a tracking number and get the Package struct

package main

import (
	"fmt"
	"github.com/unicod3/kargo"
)

func main() {
	pkg, err := kargo.Identify("1Z999AA10123456784")
	if err != nil {
		fmt.Println(err)
	}

	var trackingNumber string = pkg.TrackingNumber
	var carrier string = pkg.Carrier
	var isValid bool = pkg.IsValid
	fmt.Printf("Tracking Number: %v, Carrier: %v, Is Valid: %t",
		trackingNumber, carrier, isValid)
}

Output: Tracking Number: 1Z999AA10123456784, Carrier: UPS, Is Valid: true

For more examples please check out the test files.

Running the tests

You can run tests with standard test tool of Go:

go test -v 

Changelog

Version 1.1.2

  • Added support for USPS; IMpb, UPU S10, 20 character barcodes
  • Removed the unnecessary prefix from filenames
  • Improved the tests

Version 1.0.1

  • Fix stringutils package dependency issue

Version 1.0.0

  • Initial release

License

GNU General Public License v3.0 - see LICENSE for more details

kargo's People

Contributors

bennettmobley avatar umutuluer avatar unicod3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

umutuluer

kargo's Issues

check digit calculation

Perhaps it's my unfamiliarity with Go, but I'm seeing two small errors in how the check digit is calculated.

Comparing the code in ups.go to the algorithm described here, it appears that line 55 should subtract 48 instead of 3 from the ascii value of the character.

Line 63 should also be enclosed in an else. As it stands the running sum of calculations for characters in the odd position also includes characters in the even position as well.

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.