This is a creation in Article, where the information may have evolved or changed. [] (https://raw.githubusercontent.com/studygolang/gctt-images/master/choose-framework/heading.jpg) every day, or every few days, Someone comes to [/r/golang] (https://www.reddit.com/r/golang/) and asks questions like "which frame is the best?" ”。 I think we should try to raise this question, at least in an easy-to-understand way. You should not use frames. For a complex problem, this may be a very concise answer. This is not to say that you should not use frames at any time. As we all know, when we develop software, there is a tendency to slowly form a pattern that adapts to common development, and to speed up the development of the same thing again and again. It tries to eliminate duplicate code as much as possible. # # Standard library or STDLIBGO language standard library is of high quality. You should use it as much as you can. If you are writing an API service, you need to be familiar with the ' net/http ' package, and you will ultimately be based on this package regardless of which framework you use. Importing a third-party package into a standard library is a matter of serious consideration, and when they are dealing with a very focused issue, it is not appropriate to enter the standard library. For example, a package that generates a UUID, or a JWT package. Some packages, including web frameworks, are built on a standard library. A good concrete example, [JMOIRON/SQLX] (https://jmoiron.github.io/sqlx/) package is built on the ' sql/database ' package. # # Package Manager go and the language that contains a package market is very different. Node has [NPM] (https://www.npmjs.com/), PHP has [Packagist (composer)] (https://packagist.org/), Ruby has [gems] (https:// rubygems.org/). In fact Go does not have an official Package Manager (a Central Market), which has a significant impact on finding a package. There are several package managers available, such as [GVT] (HTTPS://GITHUB.COM/FILOSOTTILE/GVT), [glide] (Https://github.com/Masterminds/glide) and an official pilot DEP,[DEP] (HTTPS://GITHUB.COM/GOLANG/DEP) may beA time in the future bundled with the Go language toolchain. > DEP is an official test, but it's not an official tool. Read more about DEP [Roadmap] (HTTPS://GITHUB.COM/GOLANG/DEP/WIKI/ROADMAP)! In fact, Glide recommends migrating to DEP in the official Readme file. When you start using Package Manager, it is recommended that you use DEP. Go code is placed in Github,bitbucket and other repositories, and can even be hosted on your own. The most complete list of Go language packs can be found by searching Godoc, Godoc is centrally hosted by the documents generated by these packages. It does not provide a package market similar to the other language items mentioned above. There is a notable item: A little closer to the other Package manager, which is used as the package index, which is [gopkg.in] (http://labix.org/gopkg.in). Any package you create may not be used for various reasons, such as code quality. Some package authors are better known than others, and if you're looking for something as trivial as the flags configuration package, you're left with a small but high-quality choice. This is not possible in the relevant package software system. In contrast, the quality of node's package drops sharply because its focus is between the front-end and back-end, so there are many quirks of code in node, which does not exist in Go. Go is a fully server-side language, and Node often serves many of the front-end Javascript code. There is something in Node development that cannot be interpreted with any logic, such as developing and adopting [Left-pad] (Https://www.npmjs.com/package/left-pad) and [Is-array] (https:// Www.npmjs.com/package/is-array) The reason for the package. I can't explain why they have millions of downloads per week. # # Go ecosystem Go has a smaller ecosystem, but a lot of go-based projects are widely adopted, and on GitHub recently [Go-chi/chi] (Https://github.com/go-chi/chi) has 2500 stars and very good reviews (and Similar to SQLX, the Chi project was built on the underlying ' net/http ' package. We use it on [Errorhub] (https://errorhub.io/) and I suggest you use it. There are many web frameworks available, but as mentioned above, you should first use stdlib so that you canTo understand what you really need when you move on. Using the web framework itself is completely unnecessary, but when you have new requirements, you can make smarter choices about where to migrate from. # # The difference between migrating from another language to GoGo and other languages is the language details. When migrating from Python to Ruby or from PHP to Javascript, you'll find the same difference. Go is no exception. You may find that [(for example, how slices work)] (https://scene-si.org/2017/08/06/the-thing-about-slices/) is a bit confusing at first, but you will encounter these problems when migrating from any language to any other language. Let's look at an example of Ruby [predicate methods] (http://ruby-for-beginners.rubymonstas.org/objects/predicates.html). The entry threshold for Go is really low. I used PHP 15 years ago, and migrating to go is relatively straightforward. It is difficult to understand the asynchronous operation of Node, including Promise and yield. If I can recommend two reading materials, then you should read [the interview with Ryan Dahl, the creator of Node] (https://www.mappingthejourney.com/ single-post/2017/08/31/episode-8-interview-with-ryan-dahl-creator-of-nodejs/), [Bob Nystroms Critique of Asynchronous functions] (http://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/) is also a must-read. > That said, I don't think Node is the best language for building large server sites. I'm going to use Go. To tell you the truth, that's why I left Node. I realized: Oh, actually, this is not the best server-side system ever. >> **ryan dahl**## Go's power go is perfect for providing API endpoints for any project you choose to drive your front-end framework. Websockets? No problem. A bunch of Go programs that are talking to each other? Have you ever heard of Docker or Kubernetes? These systems haveIncredibly scalable, and it's written in Go. Go is an excellent language that can provide back-end logic, such as interfacing with databases and open access through HTTP API endpoints. The choice of front-end technology stacks will ensure that you can use and render this data for your browser. Are you annoyed by the React? Replace it with Vuejs without discarding any Go code. In other languages, you must strictly adhere to this principle to split the application, because normally you are not writing a server, but simply generating a script that will run in the browser producing output. Of course, using Go can use ' html/template ' in the same way, but choosing to implement the front end with a front-end framework will benefit you: developers who focus on the framework. Not everyone likes Go. You won't be using bash to write a Web server, right? # # Why do you use go? The main selling point for me is the standard library, which has a very high quality of language and documentation. Ruby,node,php and other Web development-centric languages are usually single-threaded, and if possible, beyond this range is usually an add-on, rather than a one-time citizen. Their memory management is poor (although at least PHP has improved a lot over the last 15 years), perhaps most importantly, they all belong to the scripting language category. The compiled code will always be faster than any code that runs through the interpreter. People always reinvent the wheel, not just because they can, but also because they can improve it in some way. This can be done in small increments, such as optimizing a specific function that produces a particular output, or it can be done in larger increments, such as creating a goalkeeper concurrency as the programming language for first-class citizens. Other things may not be handled (which is why there is a lot of controversy about generics in Go), but there is always room to improve. I do not rule out the possibility of others trying to provide the best generics that they deem most appropriate. People always respond to their experiences. If your experience tells you that concurrency is a problem with some XY language, you will find a solution. Migrating to go is a good way to solve this problem. # # Notes This article reflects that Go does have a package manager, but so far there are no official tools and no bundled with Go's toolchain. The previous article misled this, suggesting that Go has no package manager at all. Technically, all other package managers (at least NPM and composer) are add-ons. # # I'm honored to have you read this article ... But if you can buy a book of mine, that's great:-[API Foundations in Go] (Https://leanpub.com/api-foundations)-[Factor Apps with Docker and Go] (Https://leanpub.com/12fa-docker-golang)-[The SaaS Handbook (work in Progress) ] (Https://leanpub.com/saas-handbook) I promise you will learn more if you buy a book. Buy a copy to support me in writing more about similar topics. Thank you for buying my book. If you would like to book my consultation/Free time, please do not hesitate to send me [e-mail] (black@scene-si.org). I am very good at apis,go,docker,vuejs and extension services [et cetera] (https://scene-si.org/about).
via:https://scene-si.org/2017/10/18/choosing-a-go-framework/
Author: Tit Petric Translator: mdgsf proofreading: polaris1119
This article by GCTT original compilation, go language Chinese network honor launches
This article was originally translated by GCTT and the Go Language Chinese network. Also want to join the ranks of translators, for open source to do some of their own contribution? Welcome to join Gctt!
Translation work and translations are published only for the purpose of learning and communication, translation work in accordance with the provisions of the CC-BY-NC-SA agreement, if our work has violated your interests, please contact us promptly.
Welcome to the CC-BY-NC-SA agreement, please mark and keep the original/translation link and author/translator information in the text.
The article only represents the author's knowledge and views, if there are different points of view, please line up downstairs to spit groove
975 Reads