Expand host pattern to host list.

expandhost

Expand host pattern to host list.

E.g.:

Expand foo[01-03,06,10-12].[beijing,wuhan].bar.com, the result will be as follows:

[]string{
    "foo01.beijing.bar.com",
    "foo01.wuhan.bar.com",
    "foo02.beijing.bar.com",
    "foo02.wuhan.bar.com",
    "foo03.beijing.bar.com",
    "foo03.wuhan.bar.com",
    "foo06.beijing.bar.com",
    "foo06.wuhan.bar.com",
    "foo10.beijing.bar.com",
    "foo10.wuhan.bar.com",
    "foo11.beijing.bar.com",
    "foo11.wuhan.bar.com",
    "foo12.beijing.bar.com",
    "foo12.wuhan.bar.com",
}

Usage

import "github.com/go-project-pkg/expandhost"

func main() {
    pattern := "foo[01-03,06,10-12].[beijing,wuhan].bar.com"

    hosts, err := expandhost.PatternToHosts(pattern)
    if err != nil {
        fmt.Println(err)
    }

    fmt.Printf("%v\n", hosts)
}

Output:

[foo01.beijing.bar.com foo01.wuhan.bar.com foo02.beijing.bar.com foo02.wuhan.bar.com foo03.beijing.bar.com foo03.wuhan.bar.com foo06.beijing.bar.com foo06.wuhan.bar.com foo10.beijing.bar.com foo10.wuhan.bar.com foo11.beijing.bar.com foo11.wuhan.bar.com foo12.beijing.bar.com foo12.wuhan.bar.com]

License

This project is under the MIT License. See the LICENSE file for the full license text.

Similar Resources

A productivity tools to diagnose list of exported URL status from Google Search Console, Analytics, Sitemap URL...etc.

google-url-checker A productivity tools to diagnose list of exported URL status from Google Search Console, Analytics, Sitemap URL...etc. A quick way

Dec 31, 2021

Maven-client - A command line tool to query first order and transitive maven coordinates based off an initial list of coordinates.

maven-client Description This CLI reads a list of maven group artifact version (GAV) coordinates and returns an ordered list of first order and transi

Jan 6, 2022

MealPlanr is an application dedicated to the trivial and boring task of meal planning ๐Ÿ“… and generating a shopping list ๐Ÿ›’ .

MealPlanr is an application dedicated to the trivial and boring task of meal planning ๐Ÿ“… and generating a shopping list ๐Ÿ›’ .

MealPlanr is an application dedicated to the trivial and boring task of meal planning ๐Ÿ“… and generating a shopping list ๐Ÿ›’ .

Mar 1, 2022

Token-list - The community maintained Solana token registry

Please note: This repository is being rebuilt to accept the new volume of token

Feb 2, 2022

Our aim is to expand the capabilities of blockchain and make a secure way for transferring NFT between RMRK and MOVR blockchain.

remov Inspiration Our aim is to expand the capabilities of blockchain and make a secure way for transferring NFT between RMRK and MOVR blockchain. The

Jul 25, 2022

Go-ant-pattern: An ant pattern parser

go-ant-pattern - An ant pattern parser. Usage package main import ( "fmt" "github.com/cbuschka/go-ant-pattern" ) func main() { path := "

Dec 7, 2021

Leader-follower-pattern - Build leader-follower system pattern with etcd election

ไธปๅค‡็ณป็ปŸๆจกๅผ ๅŽŸ็† ไฝฟ็”จๅˆ†ๅธƒๅผ้”ๅฎž็Žฐไธปๅค‡่Š‚็‚น็ณป็ปŸใ€‚้€š่ฟ‡ๅฏนๅˆ†ๅธƒๅผ้”่ฟ›่กŒ็ปญๆœŸ๏ผŒไฟๆŒ้•ฟๆœŸ้”, ไปŽ่€Œไฝฟๅฝ“ๅ‰ๆœๅŠก่Š‚็‚นๅค„ไบŽไธปๆœๅŠก่Š‚็‚น ๆ— ๆณ•่Žทๅ–ๅˆ†ๅธƒๅผ้”็š„ๆœๅŠก่Š‚็‚น๏ผŒๅˆ™ไฝœไธบๅค‡้€‰

Jan 24, 2022

skipmap is a high-performance concurrent sorted map based on skip list. Up to 3x ~ 10x faster than sync.Map in the typical pattern.

skipmap is a high-performance concurrent sorted map based on skip list. Up to 3x ~ 10x faster than sync.Map in the typical pattern.

Introduction skipmap is a high-performance concurrent map based on skip list. In typical pattern(one million operations, 90%LOAD 9%STORE 1%DELETE), th

Jan 8, 2023

Display (Namespace, Pod, Container, Primary PID) from a host PID, fails if the target process is running on host

Display (Namespace, Pod, Container, Primary PID) from a host PID, fails if the target process is running on host

Oct 17, 2022

A distributed Configuration Center server that manages config in a container. The container is composed of fields (abstract layer includes: KV, LIST, DICT type). The Field contains basic datatypes (int, float, bool, string, list, dict).

A distributed Configuration Center server that manages config in a container. The container is composed of fields (abstract layer includes: KV, LIST, DICT type). The Field contains basic datatypes (int, float, bool, string, list, dict).

cassem config assembler from key-value pairs' container which include basic datatypes, such as int, string, float, bool, list, dict Features HTTP Rest

Nov 1, 2022

Simple to do list API with Gin and Gorm (with Postgres)Simple to do list API with Gin and Gorm (with Postgres)

go-todo Simple to do list API with Gin and Gorm (with Postgres) Docker Clone this repository and run: docker-compose up You can then hit the followin

Aug 29, 2022

concurrent map implementation using bucket list like a skip list.

Skip List Map in Golang Skip List Map is an ordered and concurrent map. this Map is goroutine safety for reading/updating/deleting, no-require locking

Oct 8, 2022

Todo-list - In this project using golang and mySql to create todo-list to Add and remove

Todo-list - In this project using golang and mySql to create todo-list to Add and remove

TODO-Fullstack-App-Go-Gin-Postgres-React This fullstack application creates a TODO List Web Page using the Go/Gin/Postgres/React Stack. Starting the a

Apr 7, 2022

Go-generics-simple-doubly-linked-list - A simple doubly linked list implemented using generics (Golang)

Welcome to Go-Generics-Simple-Doubly-Linked-List! Hi, This repository contains a

Jun 30, 2022

List-Utils - ๐Ÿ”ง Utilities for maintaining the list of repost sites

SMR List Utils This is a Go CLI tool that helps with managing the StopModReposts blacklist. Install Use GitHub Releases and download binary. Linux Qui

Jan 3, 2022

Shopping-list - Shopping List as part of the training

ShoppingList Shopping List as part of the training Requirements User should be a

Jan 11, 2022

A simple shopping list that keeps track of a users shopping list using charm.sh tools

Terminal Shopping List This repo is a practise project for learning practical Go. I have chosen to use a toolset called Charm as it provides a rich se

Jan 13, 2022

Generic-list-go - Go container/list but with generics

generic-list-go Go container/list but with generics. The code is based on contai

Dec 7, 2022

Multi-String Pattern Matching Algorithm Using TrieHashNode

Multi-String Pattern Matching algorithm. This implementation is inspired from Aho-Corasick algorithm Getting Started modelA = mspm.NewModel("mspm_mode

Dec 9, 2022
Shopping-list - Shopping List as part of the training

ShoppingList Shopping List as part of the training Requirements User should be a

Jan 11, 2022
A demonstration of the transactional outbox messaging pattern (+ Log Trailing) with Amazon DynamoDB (+ Streams) written in Go.
A demonstration of the transactional outbox messaging pattern (+ Log Trailing) with Amazon DynamoDB (+ Streams) written in Go.

Transactional Outbox Pattern in Amazon DynamoDB A demonstration of the transactional outbox messaging pattern (+ Log Trailing) with Amazon DynamoDB (+

Apr 12, 2022
Cleanv - Golang SDK for Vue Projects. It is able to structure a clean code/arch pattern
Cleanv - Golang SDK for Vue Projects.  It is able to structure a clean code/arch pattern

Cleanv - Golang SDK for Vue Projects Why? This project is part of my personal portfolio, so, I'll be happy if you could provide me any feedback about

Apr 24, 2022
This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event.

observer This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event. Usage go get githu

Nov 16, 2022
Host.io API Go Client

Host.io API Go Client A simple API Client written in Go for https://Host.io/ API Documentation: https://host.io/docs Examples package main import (

Dec 18, 2021
A golang SDK for creating blueprint providers for Host Factor.

Host Factor Provider SDK - Go A golang SDK for creating blueprint providers for Host Factor. Getting started Make sure to download the latest go distr

Feb 10, 2022
Awesome-go list with stars. Automatically updated

About This repository is a clone of Awesome Go but with stars. All repositories are still sorted alphabetically. Why? Some of the viewers might be aga

Jan 3, 2023
API call that accepts a list of sold Items and creates Payouts for the sellers.

Introduction As a marketplace, we need to pay our sellers for every item that has been sold on our platform. In this task, youโ€™ll be working with 2 ma

Dec 15, 2021
To-Do list in GoLang with Redis as a backend -- Sample project for proof of concepts

?? GoLang To-Do List Sample App w/ Redis ?? Description A simple to-do list app written in GoLang with Redis as a backend showing a few GoLang feature

Dec 14, 2021
A customized go list with index, sort, append, pop, count, clear and last item methods

golist A customized go list with index, sort, append, pop, count, clear and last item methods About The list data type has some more methods. Here are

Mar 6, 2022