1. 首页
  2. 主题
  3. Go Web开发

用了golang框架是否降低了开发效率

tablecell · · 2597 次点击
golang的框架只是在net/http上加上了 get/post 分类,把http.ResponseWriter, http.Request合并成一个 常用的操作封装到String/HTML/JSON 如果需要用不常用的方法,还是要调用Write/Request / Header() 该写的hundlefunc一行都少不了 如果使用框架中有些细节与预期不符,给作者提issue 你认为是bug,作者认为这是feature 比如 参考 net/http `/hello/name/` 是不匹配 /hello/name 这样的路由的 ``` package main import ( "fmt" "net/http" ) func main() { http.HandleFunc("/hello/name", func (w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Welcome to my website!") }) http.ListenAndServe(":8080", nil) } ``` $curl http://localhost:8080/hello/name/ Not found 但是很多框架 要么是算成匹配成功,反回200,有的是301,有的302 提issue 回复这是feature,不服来战,然后就卡壳了 ![bufulaizhan.jpg](https://static.studygolang.com/210906/67c9f3d0b5764f2d94843aa2bb7d0b54.jpg)
去掉还是加上 google/baidu对 seo 有不同的理解, 但是按常规,扩展以后的行为应该跟内置的类库规则一致 就象开放扩展,关闭修改的原则一样,不然就会出现开发新增一个功能,测试发现原来没问题的地方冒出两个新问题 需要不停地做回归测试,不停地在原地打转 开发效率变成往前走一步,往后退两步
#7
更多评论
看不懂楼主在说什么... 例子的代码和测试完全不符合, 一个监听80端口, 一个访问8080...
#1
1楼 <a href="/user/focusonline" title="@focusonline">@focusonline</a> 8080是另外一个框架的端口,完整的代码 ``` package main import &#34;github.com/yarf-framework/yarf&#34; type Hello struct { yarf.Resource } func (h *Hello) Get(c *yarf.Context) error { c.Render(&#34;Hello, &#34; + c.Param(&#34;name&#34;)) return nil } func main() { y := yarf.New() hello := new(Hello) y.Add(&#34;/hello/:name&#34;, hello) y.Start(&#34;:8080&#34;) } ``` $ http://localhost:8080/hello/world/
#2

用户登录

没有账号?注册

今日阅读排行

    加载中

一周阅读排行

    加载中