samedi 10 février 2018

What's the usual file structure of Golang web application

I'm coming from PHP/Laravel background and absolute beginner of Golang. So far I've built couple of Go RESTful applications but they're in just one or two files.

main.go

But, I need to make this like a real (mvc) web application with the following seperated components.

/app
/controllers
/models
/database
/migrations
...etc.

So, I have two options here.

  1. Use a Golang framework (Beego, Iris ..etc.)
  2. Use standard libraries and packages with my own custom file structure.

The problem with using a framework is, that they don't have much tutorials and community. So, there's a good chance I'll get stuck at a point struggling to go further with a framework.

The problem with using just Go and standard libraries is, there's no guidance on where to put these and those files. Should it be MVC or any other ? and collecting pieces such as...

  • DB Migration library
  • Templating Library ...etc.

Golang is now almost 10 years old, so, there should be a standard or accepted way of doing this. Can anybody explain this ?

And don't get this wrong as an opinion based question.




Aucun commentaire:

Enregistrer un commentaire