go 简介学习

gnicky · · 1387 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

/golang/src/myproject/controllers/default.go": MODIFY|ATTRIB

2016/04/26 18:52:27 [INFO] Start building...

# myproject/controllers

controllers/default.go:14: newline in string

controllers/default.go:15: syntax error: unexpected c at end of statement

2016/04/26 18:52:27 [ERRO] ============== Build failed ===================

2016/04/26 18:52:28 [SKIP] " mycode/golang/src/myproject/controllers/default.go": MODIFY|ATTRIB


如果注意到 这个情况,相当于即时编译,能够立刻看到错误。


vim ../controllers/default.go 

vim ../views/index.tpl 


目前看起来MVC的结构非常清晰,效率是不是很高?开发效率也许会上来很多?至少感觉挺直接的,标准的php or web mvc的基本概念。

index.tpl {{}}其中包括属性。controls。data[‘’]=xxxx


package controllers


import (

        "github.com/astaxie/beego"

)


type MainController struct {

        beego.Controller

}


func (c *MainController) Get() {

        c.Data["Website"] = "eego.me"

        c.Data["Email"] = "ie@gmail.com"

        c.Data["Dictionary"]="my dictionary is here"

        c.TplName = "index.tpl"

}


template file,nothing special. it's common template html files,just like any defined templates

<!DOCTYPE html>


<html>

<head>


{{.Dictionary}}

 </div>

  </header>

  <footer>

    <div class="author">

      Official website:

      <a href="http://{{.Website}}">{{.Website}}</a> /




有疑问加站长微信联系(非本文作者)

本文来自:CSDN博客

感谢作者:gnicky

查看原文:go 简介学习

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

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