- 博客(22)
- 收藏
- 关注
原创 golang http middleware实现
golang http middleware实现在登录后,可以使用中间件在处理业务逻辑前,先进行验证.自定义middleware参考func AuthOn(hFunc func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) { return http.HandlerFu...
2018-06-27 14:34:17 1250
原创 golang jwt验证
安装 go get “github.com/dgrijalva/jwt-go”登陆// Create a new token object, specifying signing method and the claims// you would like it to contain.token := jwt.NewWithClaims(jwt.SigningMethodHS256...
2018-06-27 14:32:15 1782
原创 微信小程序开发笔记
微信小程序开发笔记在点击事件触发后,通过事件传入参数可以传入event参数 在wxml中绑定事件函数 <input name='price' type="number" placeholder="price" value="{{item.price}}" bindinput='inputPrice'></inpu
2018-06-26 15:04:43 405
原创 golang excel 读取操作
golang excel 读取操作excel读取的几个步骤 - xlsx.OpenFile(filename) - for idx, sheet := range xlsFile.Sheets - for idxrow, row := range sheet.Rows - for idxcell, cell := range row.Cellspackage mainimpor...
2018-06-26 09:27:05 8383 1
原创 golang json处理
golang json处理在http json中使用其中json:"username"等字符,表示json字符串中对应的参数名称.type User struct { Username string `json:"username"` Password string `json:"password"` Nickname strin...
2018-06-26 09:25:37 437
原创 golang 结构体初始化时赋值格式
golang 结构体初始化时赋值格式:golang在给结构体赋值初始值时,用:分割k,v值 x := ItemLog{ Id: GetUuid(), ItemId: u.Id, UsrId: "123", Name: u.Name, Price: u.Price, ...
2018-06-21 20:15:15 10950
原创 golang 获取当前时间
golang time nowgolang 获取当前时间具体操作如下package mainimport ( "fmt" "time")func main() { t := time.Now() fmt.Println(t.Format("20060102150405")) fmt.Println(time.Now().Format(t...
2018-06-21 20:13:22 5350
原创 mysql date datetime timestamp
mysql date datetime timestampdatedate 只有日期,没有时间支持,mysql 中的显示格式为YYYY-MM-DD。datetimedatetime 包含日期和时间,mysql 中的显示格式为YYYY-MM-DD HH:MM:SS,时间范围 ‘1000-01-01 00:00:00’ 到 ‘9999-12-31 23:59:59’ti...
2018-06-21 20:06:44 183
原创 webkit-transform 的含义
webkit-transform 的含义-webkit 是表示针对 safari 浏览器支持,-ms表示针对 IE 浏览器支持。如下表示的是在 X 轴向右移动 50px, Y 轴向下移动 100px。div { -ms-transform: translate(50px, 100px); -webkit-transform: translate(50px, 100px);...
2018-06-20 22:58:22 44190
原创 抛出 error 异常的方式
抛出 error 异常的方式一种方式是通过 error.New 产生异常。func Sqrt(f float64) (float64, error) { if f < 0 { return 0, errors.New("math: square root of negative number") } // implementation}...
2018-06-20 22:40:46 1033
原创 golang计算字符串长度
golang计算字符串长度计算字符串长度有两种情况,一种是 ascii 字符,另一种为本地编码 (如:utf8) 的字符。package mainimport "fmt"import "unicode/utf8"func main() { fmt.Println("Hello, 世界", len("世界"), utf8.RuneCountInString("世界"))}...
2018-06-20 22:37:41 9042
原创 golang http
golang httpgolang 解析 POST 中的数据POST 的数据放在 http.Request.Body 字段,可以用 json.Decoder 解析func test(rw http.ResponseWriter, req *http.Request) { decoder := json.NewDecoder(req.Body) var t tes...
2018-06-20 22:33:28 159
原创 javascript常用函数
javascript常用函数javascript函数式编程,调用后,不修改原数据,返回运算后的新数组。reduce当提供了初始值时,初始值会放入第一次调用的accumulator变量中;否则,第一次调用的accumulator取值为array1[0],同时currentValue为array1[1]。const array1 = [1, 2, 3, 4];const re...
2018-06-20 13:52:49 158
原创 golang 中多个 defer 的执行顺序
golang 中多个 defer 的执行顺序引用 Ture Go 中的一个示例:package mainimport "fmt"func main() { fmt.Println("counting") for i := 0; i < 10; i++ { defer fmt.Println(i) } fmt.Printl...
2018-06-19 22:13:56 20129
原创 golang sql 的使用
golang sql 的使用使用 statement 增加数据使用db.Prepare获取一个 sql 执行模板,其中的?为需要输入的参数,之后通过stmt.Exec()添加参数。 Exec返回的Result可以获取 LastInsertId(),但是并不是所有数据库都支持;RowsAffected()能够获取修改数据的条数。stmt, err := db.Prepare("...
2018-06-19 21:50:41 1917
原创 golang 的 UUID 使用
golang 的 UUID 使用安装go get github.com/satori/go.uuid使用几种 UUID 的产生方式:Version 1, based on timestamp and MAC address (RFC 4122) Version 2, based on timestamp, MAC address and POSIX UID/GID (...
2018-06-19 21:39:12 12635
原创 Template Method Principle
Template Method Principle在父类中实现业务逻辑,子类中实现具体动作。在父类中实现了templateMethod,实现打印逻辑,在子类中,实现具体动作,如open,print,close等。开闭原则在扩展新的ConcreteClass时,不需要修改原AbstractClass类。其他场景分页操作,实现分页控件,在父类中实现具体的分页逻辑,子...
2018-06-17 15:42:43 136
原创 设计模式6原则
设计模式6原则Open Close Principle对修改关闭,对扩展开发.为了方便于扩展性,易于维护和升级,应该使用扩展,少修改原有代码。Liskov Subsititution Principle对于面向对象,任何基类可以出现的地方,子类一定可以出现。Dependency Inversion Principle对抽象实现,不对具体进行继承或实现。...
2018-06-17 14:26:55 140
原创 thymeleaf学习
thymeleaf学习thymeleaf为java web开发中的一种模板视图组件。变量变量表示语法: - Variable Expressions: ${…} - Selection Variable Expressions: *{…} - Message Expressions: #{…} - Link URL Expressions: @{…}<inpu...
2018-06-17 14:18:29 143
原创 java中的注解
注解的语法注解同class和interface一样,属于Java的一种类型。定义:public @interface CustomAnnotation {}使用:@CustomAnnotationpublic class Example {}元注解用于注解注解的标签元标签有 @Retention、@Documented、@Target、@Inher...
2018-06-17 12:34:46 191
原创 springmvc + thymeleaf中ajax get请求
Ajax请求简单实现在spring boot + thymeleaf环境下,利用thymeleaf的fragments模板,实现Ajax请求.主页面block<!DOCTYPE html><html lang="en" xmlns:th="http://www.w3.org/1999/xhtml"><head> <meta c...
2018-06-17 12:09:27 7567 2
原创 flask https配置
flask添加https支持先上代码from flask import Flaskfrom flask_restful import Resource, Apiapp = Flask(__name__)api = Api(app)class HelloWorld(Resource): def get(self): return {'hello': '...
2018-06-14 21:56:38 6756 1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人