How Reorganize Data From Text File Setting a Delimiter

Hello mates, I am trying to reorganize data from a .txt file defining delimiters. Example of data:

password 0.0.3 13.99.102.201:5021133.20.130.214:50212

I am trying to split this data tracking blank spaces and five bytes after the : symbol to save it into different variables. Exactly like shown below.

key = password
node = 0.0.3 
address1 = 13.99.102.201
tls1 = 50211
address2 = 33.20.130.214
tls2 = 50212

Code:

   content, err := ioutil.ReadFile(title)
	   if err != nil {
		fmt.Println("Err")
	   }
	data := strings.Split(string(content), ":")

Nevertheless strings.Split(string, ":") actually delete the delimiter instead of working as a starting point to crop the text.

Hi, I just starting by using blank as separator to get key and node. Then use the other token like input for the second pass, and then use “:” as separator.
Please check as an example (remember to add error handling :slight_smile:

1 Like

Thank you so much.

It is exactly what I was looking for