Go

Make a unique slice from an existing slice

by a small simple function.

Donald Le
Oct 16, 2020

--

Photo by Karl Lee on Unsplash

For example a slice

var simpleSlice []string
simpleSlice = append(simpleSlice, "test", "test", "donald", "ad", "thuy")

We need to convert a new slice like [“test”, “donald”, “ad”, “thuy”] by defining a new function for convert.

Running the program will show

[test donald ad thuy]

Thanks for reading my post.

Happy coding~~

--

--

Donald Le
Donald Le

Written by Donald Le

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.

No responses yet