Skip to content

Simple Bitly, Google URL Shortener API client for Go.

Notifications You must be signed in to change notification settings

huatuoxyz/go-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-shortener

Simple Bitly, Google URL Shortener API client for Go.

Usage

$ go get github.com/dongri/go-shortener
package main

import (
	"fmt"
	shortener "github.com/dongri/go-shortener"
)

func main() {

	// bitly
	b := shortener.NewBitly("{ACCESS_TOKEN}")
	shortURL, err := b.Short("http://hoge.com")
	fmt.Println(shortURL) // http://bit.ly/2DahJMA
	longURL, err := b.Long(shortURL)
	fmt.Println(longURL) // http://hoge.com/

	// goo.gl
	g := shortener.NewGoogl("{GOOGLE_API_KEY}")
	shortURL, err = g.Short("http://hoge.com")
	fmt.Println(shortURL) // https://goo.gl/hQMZ6
	longURL, err = g.Long(shortURL)
	fmt.Println(longURL) // http://hoge.com/

	// clacky.org
	c := shortener.NewClacky("{ACCESS_TOKEN}")
	shortURL, err = c.Short("http://hoge.com")
	fmt.Println(shortURL) // https://clacky.org/HuOe
	longURL, err = g.Long(shortURL)
	fmt.Println(longURL) // http://hoge.com/
}

Releases

No releases published

Packages

No packages published

Languages