News for hackers. Stuff that matters.
Re:Learn Go in five minutes by whalesalad on Tuesday January 05, 2021 @01:55PM (#25649375)
No offense to the author here ... but I need to vent some personal frustration. Every tutorial goes through these exact same motions for learning a new language. It sucks! Programmers can figure out what a variable is, or how to use an array or a map. Those things really don't change a whole lot between languages. What about how to import code from different modules? Best practices for organizing code? How your language differs from its competitors as far as usage. Testing practices (which often influence how your code is written), etc...

Learning Elixir was tough for me until I found Dave Thomas' "Elixir for Programmers" where he skipped all of the basic stuff that every programmer is assumed to know and went right to what makes Elixir unique and how to leverage it correctly. (https://codestool.coding-gnome.com/courses/elixir-for-progra...)

I have been hunting for the same thing for the Go language for years because frankly I haven't been able to grok the appeal. I am hoping to find a 'Go for Programmers' one day. I asked on Reddit a while back and was pretty much handed the "what are variables" document.

Re:Learn Go in five minutes by moksly on Tuesday January 05, 2021 @02:20PM (#25649751)
99% of the “learn programming language” literature is written by people who likely couldn’t do your job because they haven’t ever been programming.

This is why languages need good documentation.

It seems like it’s a booming industry though. I mean, there are entire sites like udemy where amateurs teach amateurs things they’ll never use in a real job, and that place, and others like it, seems to be doing just fine. Hell, every PACKT book ever written was worth more as blank paper.

Why do I care? I’m an external examiner, sometimes I need to read some of these god awful books to see what students are expected to know. I’m not sure why professors ever stray from the true CS classics, but they unfortunately do. Especially at the academy level.

Re:Learn Go in five minutes by higerordermap on Tuesday January 05, 2021 @08:09PM (#25653595)
> I’m an external examiner > sometimes I need to read some of these god awful books to see what students are expected to know.

LoL

Here in India every kid de-facto refers to few content farm websites and while they are not outright wrong, there will always be subtle errors, as the content is contributed by other students only. And books - the textbooks are so unpopular and not even available on libgen.

Day by day, academia seems more like a drug cartel.

Re:Learn Go in five minutes by cultofmetatron on Wednesday January 06, 2021 @07:28PM (#25665143)
haha its worse than you realize. I was in a cafe in jakarta and I noticed this guy was giving another guy lessons in php. We ended up talking after and I mentioned I use vue. He wanted me to teach him how to use vue so that he could run a workshop where he teaches vue!

I feel like there's something a bit off about charging money teaching a skill that I haven't personally used extensively in a professional context. I guess others feel differently

Re:Learn Go in five minutes by digianarchist on Tuesday January 05, 2021 @11:50PM (#25654752)
Packt books are woefully bad. What’s their business model? Print on demand?
Re:Learn Go in five minutes by type0 on Thursday January 07, 2021 @06:30PM (#25679143)
I wondered that to, they don't even correct simple spelling mistakes
Re:Learn Go in five minutes by dpc_pw on Tuesday January 05, 2021 @02:09PM (#25649573)
Seconded. Especially for Go, because it's mostly a lowest common denominator of language features it's not hard to write the code itself. The problem is that the module system is different and had plenty of changes along the years, What I would really like is an up to date "learn how to handle Go project in 30 minutes" tutorial (initialize new project with all best practices, add modules, publish, fork&clone&submit&pr including 3rd party submodules, test, CI, profile, debug).
Re:Learn Go in five minutes by konart on Tuesday January 05, 2021 @02:53PM (#25650146)
>What I would really like is an up to date "learn how to handle Go project in 30 minutes"

1. git init

2. git remote add %something%

3. go mod init %name_of_your_module% (where in most common case name is your repo address without the https part)

4. https://github.com/golang-standards/project-layout - this repo has the default project structure. Each subfolder has README that describes the purpose of the folder

5. go get -u github.com/gin-gonic/gin to add gin (web lib) for your project. Same for any other package. The will be added to your go.mod and go.sum files

5.1 import "github.com/gin-gonic/gin" in your code to use gin

5.2 package may have more than one major version (tag). If you want to use package at latest tag 2 - you add '/v2' when you 'go get' the package (i.e. go get -u github.com/gin-gonic/gin/v2)

6. git commit && git push to publish

7. Not sure what to you mean by 'fork&clone&submit&pr including 3rd party submodules'. You may use vendoring but in most cases you don't need it as you have your dependencies in your go.mod && go.sum files. You may want to read more about vendoring and gomodproxy though.

8. Testing is pretty easy but I guess you want and article about best practices? I won't post any link as I find the topic as too controversial regardless of the language\stack

9. CI - not sure that does this have to do with the language

10. haven't done much profiling or debugging to fill you in.

Re:Learn Go in five minutes by hactually on Tuesday January 05, 2021 @04:32PM (#25651407)
Damn.

> https://github.com/golang-standards/project-layout

I was almost with you but please don't share that repo. It's a terrible layout and the docs aren't accurate. The issues are full of Go community folk saying it's misleading and looks official but isn't.

Re:Learn Go in five minutes by konart on Wednesday January 06, 2021 @02:35AM (#25655446)
It is not official and does not say otherwise (neither do I).

We are using similar layout (albeit we just need cmd and internal directories for most of our project) and it works perfectly.

Anyway - this is not Rails or any other framework were the developer may be dependent on project structure. I just shared a possible option.

>It's a terrible

Why though?

PS: I just realized it has golang-standards in its path. Okay, this part can actually be misleading.

Re:Learn Go in five minutes by phernandez on Tuesday January 05, 2021 @05:57PM (#25652394)
I have had this issue with my current golang projects. I haven't found any clear standard for project layout. We have a bunch of microservices with grpc api endpoints, and some which are event driven. Has anyone found a better resource? As it is, even our internal projects are fairly inconsistent in their project structure, which is a bit annoying.
Re:Learn Go in five minutes by konart on Wednesday January 06, 2021 @02:52AM (#25655536)
There is no such thing as a standard here.

In our team we have most projects structured like this:

/project-folder

|

|__/build (/.gitlab-ci for projects moved to our own gitlab instance)

|

|__/cmd (folder for your entrypoints. One or more if your projects generates more than 1 binary)

   |__/bin_name1

   |__/bin_name2
|

|__/internal (folder for your sources packages)

   |__/config (package config)

   |__/http (package HTTPServer, api, etc)

      |__/api

      |__/models

   |__/database (package database)

   |__...
|

|__/api (swagger and such)

|

|__/docs (godoc)

|

|__/.golangci.yml

|

|__...

Something like this.

Re:Learn Go in five minutes by dpc_pw on Wednesday January 06, 2021 @12:23PM (#25659872)
> Not sure what to you mean by 'fork&clone&submit&pr including 3rd party submodules'.

Sometimes a 3rd party library needs a fix, and you want to fork it, add your changes, and run with it like that until your changes land in the upstream.

Last time I had to deal with it was a PITA, because libraries were fully qualified, and now I wanted to make an override. In Rust I would use https://doc.rust-lang.org/cargo/reference/overriding-depende...

Re:Learn Go in five minutes by konart on Thursday January 07, 2021 @12:55PM (#25674572)
Oh! I get in now.

In Go you can 'replace' a required package.

https://thewebivore.com/using-replace-in-go-mod-to-point-to-...

You can replace with local or remote package (for example if you have published fixed version somewhere and what your teammates to use it too until your changes land in the upstream.)

Re:Learn Go in five minutes by nickelcitymario on Tuesday January 05, 2021 @02:06PM (#25649537)
> How your language differs from its competitors as far as usage.

Yes! I'm always tempted to ask "How is this different or better than XYZ lang?"

I don't have the time/inclination to learn every new fangled language that comes by, so it would be nice to have an easy way to understand what scenarios any given language is best suited for.

For example, every time I read about Go, I'm left wondering: How is this better than C or Java? Presumably it's better in some ways I'm not perceiving, otherwise why would it be built and used?

Re:Learn Go in five minutes by echlebek on Tuesday January 05, 2021 @07:40PM (#25653395)
Competent programmers can learn Go directly from the spec https://golang.org/ref/spec, the playground https://play.golang.org/, and the standard library docs https://golang.org/pkg/.
Re:Learn Go in five minutes by 8589934591 on Wednesday January 06, 2021 @06:30AM (#25656751)
It would be nice to have a collection of resources for each language for whatever you have mentioned above. It'd be very helpful to just deep dive and learn any language than focusing on declaring variables and for loops.
Re:Learn Go in five minutes by whalesalad on Wednesday January 06, 2021 @07:22AM (#25657067)
A hacker wiki of sorts. It’s a great idea.
Re:Learn Go in five minutes by codenlearn on Tuesday January 05, 2021 @02:12PM (#25649624)
One resource that atleast comes close to what you are talking about is the information at go101.org, not sure if you have seen this before. Especially the section on Go Type System and Concurrent Programming is really very good and they focus on how to leverage the feature correctly for the most part. Hopefully you like it https://go101.org/article/101.html
Re:Learn Go in five minutes by joshspankit on Wednesday January 06, 2021 @09:28AM (#25658011)
Would you be up for venting that frustration in to a git repo and setting the tone by making public exactly that type of thing for the languages you do know?

Asking for a friend

Re:Learn Go in five minutes by whalesalad on Wednesday January 06, 2021 @11:09AM (#25658942)
You have presented an interesting challenge. I am going to chew on this and see what can be done. Good question.
Re:Learn Go in five minutes by url00 on Tuesday January 05, 2021 @02:03PM (#25649506)
This 100x. If you find it please share with the rest of us!
Re:Learn Go in five minutes by dinkleberg on Tuesday January 05, 2021 @04:48PM (#25651612)
That elixir course looks fantastic, thanks for linking it.