Is there learning go lang website?

I am a developer of c/c++. I started studying golang from today.
Go lang is similar to c/c++ and is simple so I think I will get used to it soon.
After studying for about an hour, there is a difference in syntax than I thought, but I don’t know how to solve it, so the process is slow.
For this reason, I would like to find a grammar that matches exactly c++.
Are there any helpful websites? I meet situations where even the following very simple array, variables, initializations, and repetitive statements are difficult, and they work differently than the intended situation.

like this…

std::vector<std::string> test; // empty container ok
std::vector<std::string> test(2,"test"); // ok
std::vector<std::string> test = {"123","123123"} // ok
==> assignable by constructor and copy assignment through equal operator, so it's possible

go lang

var test []string //ok 
var test []string = {"123","345","456"} // not work
test := []string{"123","345","456"} // ok

==> i don't know why its not working or working
1 Like

Take the tour and if you want, read the Go Programming Language Specification.


thank you ~

What example code will make my golang skill grow faster?

I always recommend to get a copy of the book “The Go Programming Language”.

And as with any programming language the advise is to start with small projects to solve and try to be part of the Go community.

1 Like

The var keyword in Go only declares a identifier of a type . you cannot assing any value at that time.
While the short declaration := operator in Go declares an identifier as well as assigns a value to it.

Apart from language specification, see the Effective Go also.

See and learn from-

So according to what you say, var foo int = 1 ist invalid?

corrigendum : * slices

  • slices
    i missed that

As slices are compounds, you just need to construct them.properly.

I can’t test, as this is my mobile but the following should work, though I wouldn’t actually do it because that repetition annoys me.

var s []string = []string{"a", "b", "c"}
1 Like

There are many ways to learn, the above are all good paths.

I used this course to jumpstart my entry into Go:

The best courses that I’ve found are Jon Calhoun’s courses. He has free courses on algorithms and some “gophercises”. He also has a paid web development course which is the best source that I have found on the subject.

The strength of Jon Calhoun is that, unlike many courses on Udemy, he actually explains how to put things together instead of just reading package documentation out loud.

He has a great discount during the pandemic. The best budget option for the web development course it to just get his book without screencasts, ~$40. The full course with screencasts is about $150, and very much worth it.

Or you can simply write:

var s = []string{"a", "b", "c"}

var keywoard is able to understand what type is after = sign.

1 Like

var test []string = {“123”,“345”,“456”}
var test []string =[]string {“123”,“345”,“456”}
test := []string{“123”,“345”,“456”}


sorry icant read this

That’s Chinese. You need a translation

No, you need to write English.


Recently digital ocean exposed us an wonderful content. Enjoy it! :smiley:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.