gopuny

command module
v0.0.0-...-c03a438 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2019 License: MIT Imports: 4 Imported by: 0

README

GoPuny

GoPuny Build Status MIT license Go Report Card Maintainability

A package and CLI tool to use SAPO's URL shortening service.

Install

$ go get github.com/olshevskiy87/gopuny

Usage

  1. CLI tool gopuny
$ gopuny -h
Usage: gopuny ACTION URL

Positional arguments:
  ACTION                 "short" or "expand"
  URL                    url to short or expand

Options:
  --help, -h             display this help and exit
$ gopuny short https://www.google.com
Unicode   http://㐃鍍.sl.pt
ASCII     http://37.sp.sl.pt
Preview   http://37.sp.sl.pt/-
Original  https://www.google.com
$ gopuny expand http://37.sp.sl.pt
https://www.google.com/
  1. Using package punyurl
package main

import (
	"fmt"
	"os"

	"github.com/olshevskiy87/gopuny/punyurl"
)

func main() {
	puny, err := punyurl.New("https://www.google.com")
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	result, err := puny.Short()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	fmt.Printf("%#v\n", result)
	// output:
	// &result.Result{ASCII:"http://37.sp.sl.pt", Preview:"http://37.sp.sl.pt/-", Puny:"http://㐃鍍.sl.pt", URL:"https://www.google.com"}
}

Motivations

Inspired by perl-module WWW::Shorten::PunyURL

License

MIT. See LICENSE for details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL