I've started to learn the Go, and I know the C++ language. Can work with slices or lists in go in the same way in C++? For example, in C++ we can use iterators for point to the position in a collection, like it shown above:
#include <list>
int main() {
std::list<int> list = {1,1,2,3,1,4,5,6,7,8,1,1,9,10};
auto it = std::find(list.begin(), list.end(), 3);
// Now I can use the 'it' for insert items, remove/transform diaposonces etc.
++it;
list.erase(it, std::remove(it, list.end(), 1);
}
And iterate forward/back as we wish. What is a good practice for tasks like this? What is the most efficient way to work with iterators in Golang?
Go and C++ are very different languages. Don't try to use C++ STL style in Go. Other Go programmers won't see what you are trying to do.
Almost all Go code I've worked with uses array/slice indexes not iterators. In the odd case that a linked list makes sense you only hold head, tail pointers.
Trying to write STL style code needs templates that Go does not have. Trying to write “generic” code in Go results in horrific disasters of interface{} and reflection that read ugly and perform 5x worse than they should.
Just write Go style code in Go.