In the first article we setted up our environment. Now, we will create our first application: an HTTP REST API Server in Go.
Initializati...
For further actions, you may consider blocking this person and/or reporting abuse
Correction the cloned instance of go-rest-api is working. It was my effort to duplicate this setup in a localized project folder where the issues come into play.
Hi, so is it working finally?
Yes the downloaded git version of go-rest-api is working. It is when I attempt to create a local copy that I run into issues. I'm struggling with what needs to be a module versus just a regular local package and getting the import references working correctly. I've yet to see any clear documentation regarding the use of modules versus just local packages and how to structure project correctly. So, I'm spinning my wheels in attempts to come to a self understanding regarding modules in the combination with imports. As a beginner, the last thing I want to do is to start pushing worthless code to GitHub. I'm on POP!_OS and using VScode. VScode seems to be getting in the way at times too. Anyway, thanks for making available various examples I've learned a lot from them. I'll continue my struggle with Golang, but I seriously do not understand why it has to be so complicated.
Thank you very much! This is a great course.
Thank you so much!
Thank you very much. I learned a lot. My dev environment is Ubuntu and had problems installing Swagger. Able to use docker method to run it, but in Taskfile.yml I had to change 'cmds' to included the entire docker run command. Otherwise no other issues. I can't wait for next one. also Definitely blues-gopher is my favorite one.
Thanks Dan for your feedback 🙂.
I had problem in the past with installing swagger in a VM With Ubuntu too (4-5 years ago).
Yes using sicker image is a good solution and with Taskfile you can add or edit tasks it's a good way 👍
Ohh you like the blues gophers 😊 I love them too, the color match very well with gophers.
I'll publish another article next Wednesday I think 🤞💪
Thank you, good content. I run into a problem when generating files. When running the cmd: "task swagger.gen". did not generate the files needed. I got the error msg: "go: not generating in packages in dependency modules". any help
In Taskfile, you could just replace "github.com/scraly/learning-go-by-examples/go-rest-api/internal" for your own module name.
im having the same problem im using the "task swagger.gen" i tried to swich de version of my language but im running to the same problem
heads up, if your doing this on an apple m1 machine i believe you'll need to add "--platform linux/amd64" to the taskfile on the docker command. :)
also sorry aurélie i accidentally posted this comment to part 1.
Thanks Michelle.
I didn't test on M1 for the moment, I'll do it and update the article .
Thank you very much.
I repeated this code following you. But I have a problem with URL localhost:8080
It return
{"code":404,"message":"path /gopher/ was not found"}
because 'required: true' in swagger.yml for
/gopher/{name}:
Hi, thanks, yes if you follow the "let's test our app" part, I test "/healthz" route, "/hello/aurelie" and "gopher/dr-who" route :-) .
Never "/gopher" alone.
The goal is to retrieve an existing gopher so you can test with a gopher name ;-).
I've learned much trying to getting the tutorials to work, but all tutorials are failing to execute for one reason or another. This includes the tutorials cloned with git. The last tutorial was the go-rest-api and very much like the approach but not repeatable for me.
I'm just getting started with Golang and finding it very frustrating not being able to find functional tutorials. Anyway, when I'm more experienced I'll come back to these tutorials and see what my newbie issues were.
localized copy of go-rest-api now working.
Issue 1: 'task gen' not generating server code in /pkg/swagger
change to /pkg/swagger and executing 'go generate gen.go' worked.
Issue 2: Had to manually set import statement in server.go to match the git version
Issue 3: go.mod had to be manually created to match the git version.
VScode is issuing a warning that 'io/ioutil' has been deprecated since Go 1.16
💪
thanks for your remark about io/ioutil package:
pkg.go.dev/io/ioutil
Amazing!!! Thank you again Aurélie
@aurelievache thank you, i think you need to add the command
in
Let's build our app...
i think you need to add
go mod tidy
before
go build -o bin/go-rest-api internal/main.go
,Peace out
I am getting started with go and I have learnt a lot including best practices using your example. Kudos.
Thanks for this kind comment ♥️
I believe that you are a good technical leader and mentor Aurelie. To explain in an easy way is one of the most challenging part of being a good leader! Enjoying your post! Keep them coming! Cheers,
Thanks Anit 🥰