A golang library for packing and unpacking hosts list

Overview

hostutils

License Build Status Go Report Card codecov GoDoc

A golang library for packing and unpacking hosts list

Install

go get github.com/Wing924/hostutils

Examples

package main

import (
    "fmt"

    "github.com/Wing924/hostutils"
)

func main() {
  // Pack
  pack1 := hostutils.Pack([]string{"example101z.com", "example102z.com", "example103z.com"})
  fmt.Println(pack1) // [example[101-103]z.com]

  pack2 := hostutils.Pack([]string{"example101z.com", "example102z.com", "example201z.com"})
  fmt.Println(pack2) // [example[101-102,201]z.com]

  pack3 := hostutils.Pack([]string{"example01z.com example02z.com"})
  fmt.Println(pack3) // [example[01-02]z.com]

  // Unpack
  unpack1 := hostutils.Unpack([]string{"example[101-103]z.com"})
  fmt.Println(unpack1) // [example101z.com example102z.com example103z.com]

  unpack2 := hostutils.Unpack([]string{"example[1-2][101-102]z.com"})
  fmt.Println(unpack2) // [example1101z.com example1102z.com example2101z.com example2102z.com]
}

Functions

func Normalize(hosts []string) (packedHosts []string)
    Normalize Unpack and pack hosts

func NormalizeString(hosts string) (packedHosts []string)
    NormalizeString Unpack and pack hosts

func Pack(hosts []string) (packedHosts []string)
    Pack Pack full hosts list into short abbreviated hosts.

func PackString(hosts string) (packedHosts []string)
    PackString Pack space septated full hosts list into short abbreviated
    hosts.

func Unpack(packedHosts []string) (hosts []string)
    Unpack Unpack short abbreviated hosts into full hosts list.

func UnpackString(packedHosts string) (hosts []string)
    Unpack Unpack space septated short abbreviated hosts into full hosts
    list.
Issues
Releases(v1.0.1)
  • v1.0.1(Oct 25, 2018)

  • v1.0.0(Oct 3, 2017)

    func Normalize(hosts []string) (packedHosts []string)
        Normalize Unpack and pack hosts
    
    func NormalizeString(hosts string) (packedHosts []string)
        NormalizeString Unpack and pack hosts
    
    func Pack(hosts []string) (packedHosts []string)
        Pack Pack full hosts list into short abbreviated hosts.
    
    func PackString(hosts string) (packedHosts []string)
        PackString Pack space septated full hosts list into short abbreviated
        hosts.
    
    func Unpack(packedHosts []string) (hosts []string)
        Unpack Unpack short abbreviated hosts into full hosts list.
    
    func UnpackString(packedHosts string) (hosts []string)
        Unpack Unpack space septated short abbreviated hosts into full hosts
        list.
    
    Source code(tar.gz)
    Source code(zip)
Owner
Wei He
I have a cat.
Wei He
Onboarding exercise to create todo list using golang and postgres

Todo List API Description A RESTful API that allows a user to create, update, view, filter, and delete todos API Documentation Copy the contents of th

null 0 Dec 1, 2021
Hack this repo and add your name to the list above. Creativity and style encouraged in both endeavors.

Hack this repo and add your name to the list above. Creativity and style encouraged in both endeavors.

Danger 2 Oct 1, 2021
Listmonk - a standalone, self-hosted, newsletter and mailing list manager

listmonk is a standalone, self-hosted, newsletter and mailing list manager. It is fast, feature-rich, and packed into a single binary. It uses a Postg

null 0 Jan 13, 2022
Takes a list of poker hands for two players in STDIN and scores them

Poker Hand Sorter Takes a list of poker hands for two players in STDIN and scores them. Returns the number of hands won by each player. Prerequisites

Rylee 0 Jan 16, 2022
CoreFoundation Property List support for Go

PACKAGE package plist import "github.com/kballard/go-osx-plist" Package plist implements serializing and deserializing of property list

Lily Ballard 27 May 21, 2021
A simplistic todo list manager written in Go

Tasks Tasks is a simplistic Go webapp to manage tasks, I built this tool to manage tasks which I wanted to do, there are many good kanban style boards

Suraj Patil 523 Jan 19, 2022
Library to work with MimeHeaders and another mime types. Library support wildcards and parameters.

Mime header Motivation This library created to help people to parse media type data, like headers, and store and match it. The main features of the li

Anton Ohorodnyk 25 Dec 13, 2021
Flow-based and dataflow programming library for Go (golang)

GoFlow - Dataflow and Flow-based programming library for Go (golang) Status of this branch (WIP) Warning: you are currently on v1 branch of GoFlow. v1

Vladimir Sibirov 1.3k Jan 17, 2022
A simple Cron library for go that can execute closures or functions at varying intervals, from once a second to once a year on a specific date and time. Primarily for web applications and long running daemons.

Cron.go This is a simple library to handle scheduled tasks. Tasks can be run in a minimum delay of once a second--for which Cron isn't actually design

Robert K 208 Nov 15, 2021
GoLang Library for Browser Capabilities Project

Browser Capabilities GoLang Project PHP has get_browser() function which tells what the user's browser is capable of. You can check original documenta

Maksim N. 39 Nov 13, 2021
Type-safe Prometheus metrics builder library for golang

gotoprom A Prometheus metrics builder gotoprom offers an easy to use declarative API with type-safe labels for building and using Prometheus metrics.

Cabify 92 Oct 6, 2021
Simple licensing library for golang.

license-key A simple licensing library in Golang, that generates license files containing arbitrary data. Note that this implementation is quite basic

Hyperboloide 230 Jan 14, 2022
A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell.

shellwords A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell. Installation go get github.com/Wing924

Wei He 16 Nov 20, 2021
a Go (Golang) MusicBrainz WS2 client library - work in progress

gomusicbrainz a Go (Golang) MusicBrainz WS2 client library - a work in progress. Current state Currently GoMusicBrainz provides methods to perform sea

Michael Wendland 44 Jan 1, 2022
ghw - Golang HardWare discovery/inspection library

ghw - Golang HardWare discovery/inspection library ghw is a small Golang library providing hardware inspection and discovery for Linux and Windows.

Jay Pipes 1.1k Jan 13, 2022
Golang SSR-first Frontend Library

kyoto Library that brings frontend-like components experience to the server side with native html/template on steroids. Supports any serving basis (ne

Yurii Zinets 459 Jan 19, 2022
GoLang Library for Browser Capabilities Project

Browser Capabilities GoLang Project PHP has get_browser() function which tells what the user's browser is capable of. You can check original documenta

Star Inc. 0 Nov 23, 2021
A WSL Library for Golang.

wsllib-go A WSL Library for Golang. Usage Get this package go get

yuk7 5 Dec 3, 2021
Go-linq - A powerful language integrated query (LINQ) library for Golang

go-linq A powerful language integrated query (LINQ) library for Go. Written in v

Ahmet Alp Balkan 2.8k Jan 14, 2022