hostutils

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(hosts []string) (packedHosts []string)

Normalize Unpack and pack hosts

func NormalizeString

func NormalizeString(hosts string) (packedHosts []string)

NormalizeString Unpack and pack hosts

func Pack

func Pack(hosts []string) (packedHosts []string)

Pack Pack full hosts list into short abbreviated hosts.

func PackString

func PackString(hosts string) (packedHosts []string)

PackString Pack space septated full hosts list into short abbreviated hosts.

func Unpack

func Unpack(packedHosts []string) (hosts []string)

Unpack Unpack short abbreviated hosts into full hosts list.

func UnpackString

func UnpackString(packedHosts string) (hosts []string)

UnpackString Unpack space septated short abbreviated hosts into full hosts list.

Types

This section is empty.

Jump to

Keyboard shortcuts

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