Having a rough time getting started with golang

xuanbao · · 367 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hello, I&#39;ve been trying to learn go for the past two days, but I feel like I haven&#39;t made much progress. Since I know how to make basic/intermediate PHP web applications and have had some experience in c# and java I thought learning go would&#39;ve been a smooth ride. I think it&#39;s fair to say I have overestimated my capabilities. </p> <p>I feel like I&#39;m just having a hard time grasping the main concept behind it; what exactly is go. I&#39;ve always like to code everything as barebones as possible (no framework and minimal libraries) to make my web apps and therefore thought go would fit my needs since it seems to do the job of apache and PHP at the same time. Was I wrong? Every time I try to look for a tutorial they always talk about frameworks and there seems to be many. Is &#34;raw&#34; go only use for specific server-side scripts or can you make a whole web app from scratch only using go?</p> <p>Do you guys have any tips or good resources for learning go or making a go web application from scratch (w/o framework) or am I looking in the wrong place? Thank you very much for your help!</p> <hr/>**评论:**<br/><br/>PacNinja: <pre><p>Sticking to stdlib(+ router if needed) is what the <a href="https://www.reddit.com/r/golang/search?q=web+frameworks&amp;restrict_sr=on&amp;sort=relevance&amp;t=all" rel="nofollow">community recommends</a>.</p> <p>Resources:</p> <ul> <li><a href="https://tour.golang.org/welcome/1" rel="nofollow">Tour of Go</a>: Language basics</li> <li><a href="https://golang.org/doc/articles/wiki/" rel="nofollow">Official tutorial on Writing Web Apps</a>: For learning basic program structure of a web app<br/></li> <li><a href="https://godoc.org/net/http" rel="nofollow">net/http docs</a>: For general reference</li> <li><a href="https://thewhitetulip.gitbooks.io/webapp-with-golang-anti-textbook/content/" rel="nofollow">web-dev-golang-anti-textbook</a>: Covers almost everything(auth, templates, db etc.) you need for a web app and it doesn&#39;t use any frameworks.</li> <li><a href="https://medium.com/@benbjohnson/structuring-applications-in-go-3b04be4ff091" rel="nofollow">Structuring Applications in Go</a>: Teaches you how to structure your web app</li> </ul> <p>Tips: Read the docs.!</p></pre>thewhitetulip: <pre><p><a href="https://www.youtube.com/playlist?list=PL41psiCma00wgiTKkAZwJiwtLTdcyEyc4" rel="nofollow">https://www.youtube.com/playlist?list=PL41psiCma00wgiTKkAZwJiwtLTdcyEyc4</a></p> <p>Is the youtube series based on web-dev-golang-anti-textbook linked above.</p></pre>slrz: <pre><p>Don&#39;t ever search for tutorials. That word somehow triggers search engines to return you the most filthy crap content the web has to offer.</p></pre>dmikalova: <pre><p>Yeah all the tutorials are at best extremely specific. Better to just get a book.</p></pre>chmikes: <pre><p>There is no need for a framework. I do use some of the gorilla tools (<a href="http://www.gorillatoolkit.org/" rel="nofollow">http://www.gorillatoolkit.org/</a>), but only where I really need it (e.g. Mux). I minimize external dependencies to avoid making my life a nightmare by keeping all packages up to date and working well together. Sticking with stdlib is the most popular policy. </p> <p>But it takes time to learn how to do it properly. It is not easy to learn from the Go documentation. Go by example is good to have a dip in Go but not to learn all possibilities and master the language and its libraries. There is a gap there that still needs to be filled. </p></pre>TransistorNetwork: <pre><p>Not sure if you have already completed it but the Go tour is a really great place to start learning the language: <a href="https://tour.golang.org/welcome/1" rel="nofollow">https://tour.golang.org/welcome/1</a></p> <p>I realize its not about web apps but it gives you exposure to a lot of go libraries you might need regardless of what you are doing.</p></pre>carsncode: <pre><p>You can absolutely just use the standard library and I recommend it for most cases, especially when you&#39;re just learning Go. I recommend the basic walkthrough on the official site, it&#39;ll get you started with the basic concepts using just the standard library. Then pick a problem you want to solve in go and take it from there - with few vanilla go tutorials to go on, you&#39;ll have to forge your own by just building a project. Even if it doesn&#39;t turn out well, it&#39;ll give you direction in your learning.</p></pre>itsmontoya: <pre><p>I use the stdlib almost exclusively with my projects. One if the great things about go is that you can do so much with only using stdlib. When you need something extra, there is USUALLY a library for it.</p></pre>drailing: <pre><p>Started with go a few weeks ago, but just with the first http handler I need to search for a router, isn&#39;t it? Things like url parameters or declarative GET / POST handling is not included, or did I miss something?</p></pre>sethammons: <pre><p>URL parameters (/resource/:id) and automatic routing for GET / POST: you can roll your own and it is not overly difficult. However, when you need these, I recommend the Gorilla Toolkit. It is not a framework, but a collection of packages that make things like this easier than rolling your own. </p></pre>itsmontoya: <pre><p>Julian Schmidt&#39;s http router or Gorilla Mux is solid for URL params</p></pre>drailing: <pre><p>I found <a href="https://husobee.github.io/golang/urlrouter/vestigo/2015/09/22/vesigo.html" rel="nofollow">https://husobee.github.io/golang/urlrouter/vestigo/2015/09/22/vesigo.html</a> </p> <p>Searched for a router only, because I read everywhere the std lib fits for most cases. Second I added gorm</p></pre>metamatic: <pre><p>I use <a href="https://godoc.org/github.com/bouk/httprouter" rel="nofollow">https://godoc.org/github.com/bouk/httprouter</a> because it&#39;s as solid as httprouter, but supports Context and standard method signatures.</p></pre>klippos: <pre><p>Hey,</p> <p>I was like you few months back. I wanted to learn Go but had very difficult time to understand it and make something of it. I tried for 2weeks and put this aside to return to my old Python.</p> <p>And recently, with a personal Python project (in microservices), I was asking myself: &#34;let&#39;s give it another chance, pretty sure I can do something&#34;.</p> <p>I took one of the service and try to rewrite it in Go. When I didn&#39;t understand something I went into the doc and try to see what&#39;s was going on there: - What this func do and what it return. </p> <p>As of today, the service was rewritten in Go and is functional ! It&#39;s not the best and pretty code over there but it&#39;s working. I continued with some unittest &lt;- very important, didn&#39;t really bother with it before but it helps me to see that certain parts of my code wasn&#39;t good or could be better.</p> <p>Word of advice, <strong>don&#39;t give up</strong> ! It can be difficult, sometime really annoying but when you start to understand even an little piece of it, you&#39;ll be happy that you didn&#39;t.</p></pre>proyb2: <pre><p>You could write a basic web application or websites from scratch. If you do not feel making progress, it is normal. We struggle because from your experience is different from Go syntax. It is always an alien for most programmers learning new languages. Learning how to code for a website maybe a bad idea, you should consider benchmarking different languages to get the idea how fast does it perform with as low as C before you adopt it.</p> <p>Hacking enough knowledge with Go before you adopt a web framework. </p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

367 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传