内容简介:1)beego框架安装go get github.com/astaxie/beego2)bee工具安装
1)beego框架安装
go get github.com/astaxie/beego
2)bee工具安装
go get github.com/beego/bee
(bee工具使用)https://beego.me/docs/install/bee.md
3)Mac 下配置path环境
export GOPATH=${HOME}/go
export PATH=${PATH}:${GOPATH}/bin
4)创建API服务
bee api
学习相关:
1)beego路由配置:
https://blog.csdn.net/qq_33610643/article/details/53511275
路由实践 https://www.cnblogs.com/hezhixiong/p/4602671.html
2)学习ERP进销存演示代码
3)学习语法
Go 程序的一般结构: basic_structure.go
// 当前程序的包名
package main
// 导入其他包
import . "fmt"
// 常量定义
const PI = 3.14
// 全局变量的声明和赋值
var name = "gopher"
// 一般类型声明
type newType int
// 结构的声明
type gopher struct{}
// 接口的声明
type golang interface{}
// 由main函数作为程序入口点启动
func main() {
Println("Hello World!")
}
Go 程序是通过 package 来组织的。
只有 package 名称为 main 的包可以包含 main 函数。
一个可执行程序有且仅有一个 main 包。
通过 import 关键字来导入其他非 main 包。
可以通过 import 关键字单个导入:
import "fmt"
import "io"
也可以同时导入多个:
import {
"fmt",
"io"
}
使用
package 别名:
// 为fmt起别名为fmt2
import fmt2 "fmt"
省略调用(不建议使用):
// 调用的时候只需要Println(),而不需要fmt.Println()
import . "fmt"
前面加个点表示省略调用,那么调用该模块里面的函数,可以不用写模块名称了:
import . "fmt"
func main (){
Println("hello,world")
}
通过 const 关键字来进行常量的定义。
通过在函数体外部使用 var 关键字来进行全局变量的声明和赋值。
通过 type 关键字来进行结构(struct)和接口(interface)的声明。
通过 func 关键字来进行函数的声明。
可见性规则
Go语言中,使用大小写来决定该常量、变量、类型、接口、结构或函数是否可以被外部包所调用。
函数名首字母小写即为private :
func getId(){}
函数名首字母大写即为 public :
func Printf(){}
---------------------
其他语法包括,类,结构,接口,变量指针如何写。
4)结构,接口,类
Golang系列(一)之顺序编程
https://blog.csdn.net/huwh_/article/details/78429965
Golang系列(二)之面向对象编程
https://blog.csdn.net/huwh_/article/details/53710495
Golang系列(三)之并发编程
https://blog.csdn.net/huwh_/article/details/74858134
Golang系列(四)之面向接口编程
https://blog.csdn.net/huwh_/article/details/79054450
Golang系列(五)之Golang指针
https://blog.csdn.net/huwh_/article/details/77879970
Golang系列(七)之常用包
https://blog.csdn.net/huwh_/article/details/53710530
所有教程
https://www.huweihuang.com/golang-notes/
语言的学习
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 安装golang web框架 gin
- 安装并使用Golang的Gin框架
- Yar RPC 框架安装与基础使用
- golang 使用beego框架安装bee 报错
- Python网络框架Django和Scrapy安装指南
- Centos7.5安装部署Golang、Beego框架
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Release It!
Michael T. Nygard / Pragmatic Bookshelf / 2007-03-30 / USD 34.95
“Feature complete” is not the same as “production ready.” Whether it’s in Java, .NET, or Ruby on Rails, getting your application ready to ship is only half the battle. Did you design your system to......一起来看看 《Release It!》 这本书的介绍吧!