
golang
文章平均质量分 58
fareast_mzh
A glitch in the Matrix
展开
-
golang 开发环境 配置 go语言 liteIDE
https://www.cnblogs.com/mingzhanghui/p/9384781.htmlMac:* 下载go安装包 go语言中文网 ** 通过源码编译安装需要先安装go1.4wget https://studygolang.com/dl/golang/go1.10.3.src.tar.gztar xvzf go1.10.3.src.tar.gz -C ....原创 2018-07-29 11:32:00 · 779 阅读 · 0 评论 -
golang 实现js 数组 indexOf函数 根据元素找到数组下标
在数组中找到一个元素的下标,找不到返回-1在javascript中可以这样写:var a = ['a','b','c','d']console.log(a.indexOf('c')) // 2* index.goimport ( "fmt" "strings")type CompareFunc func(interface{}, interface{}) int...原创 2019-03-18 19:00:57 · 9640 阅读 · 0 评论 -
golang 年级转换入学年份
* map.txt '高三' => '03-2016', '高二' => '03-2017', '高一' => '03-2018', '初三' => '02-2016', '初二' => '02-2017', '初一' => '02-2018', '小六' => '01-2013', // 五四制的初中 '六年级'=&...原创 2019-03-19 09:53:37 · 803 阅读 · 0 评论 -
golang xorm 示例 返回临时变量的引用
golang xormhttp://www.xorm.io/docs/// var engine *xorm.Enginevar everyone []Userinfoerr := engine.Find(&everyone)golang 可以返回临时变量的引用, 不会panicxorm 数据库表 实体类定义实体类Entity中有 func (* Ent...原创 2019-03-23 15:57:15 · 1905 阅读 · 0 评论 -
golang 数组、切片用法
* declare.gopackage mainimport ( "fmt")type ElementHandler func (interface{})func slice_for_each(arr []interface{}, n int, fn ElementHandler) { for i := 0; i < n; i++ { fn(arr[i]) }...原创 2019-03-30 22:45:29 · 274 阅读 · 0 评论 -
golang API server 利用redis实现session
参照https://laravel.com/docs/5.8/session* Session.gopackage tokenimport ( "encoding/json" "fmt" "github.com/go-redis/redis" "strings" "time")type Session struct { Driver *redis.Clien...原创 2019-04-04 16:46:25 · 1899 阅读 · 0 评论 -
golang 3DES 加密
key, iv 自己随意设定为了让结果可正常打印输入显示,都经过base64处理* TripleDES.gopackage authimport ( "bytes" "crypto/cipher" "crypto/des" "encoding/base64")type TripleDES struct { key string iv string}...原创 2019-03-27 13:16:57 · 1838 阅读 · 0 评论 -
golang 错误码
* errno.gopackage errnoimport "fmt"type Errno struct { Code int Message string}func (err *Errno) Error() string { return err.Message}func (this *Errno) Add(msg string) *Errno { thi...原创 2019-04-10 11:40:09 · 1227 阅读 · 0 评论 -
golang 并发求素数 prime number CSP
https://36kr.com/p/5073181“Problem: To print in ascending order all primes less than 10000. Use an array of processes, SIEVE, in which each process inputs a prime from its predecessor and prints it....原创 2019-04-02 10:21:20 · 799 阅读 · 0 评论 -
golang 多级json生成 地区列表
golang map用法https://ashitani.jp/golangtips/tips_map.html* map.gopackage mainimport ( "encoding/json" "log" "fmt")func main() { var provinceList []interface{} var districtList []int...原创 2019-04-02 16:59:30 · 2022 阅读 · 0 评论 -
emacs auto-complete
Emacs安装auto-complete分别下载各个el文件auto-complete-mode 主源码库https://github.com/auto-complete/auto-complete把zip文件下载后,复制auto-complete.el、auto-complete-config.el和dict文件夹到放插件的文件夹(这里是~/.emacs.d/plugins/au...转载 2019-04-09 09:34:57 · 969 阅读 · 0 评论 -
golang xorm Model 模型文件模板
* Record.gopackage modelsimport ( "fmt" "github.com/go-xorm/xorm" "time")// 用户首次登录type FirstLoginRecord struct { Id int64 `xorm:"not null pk autoincr INT(11)"` UserID int64 `json:"userid...原创 2019-04-09 12:03:50 · 1496 阅读 · 0 评论 -
golang urlencode
* url.gopackage mainimport ( "fmt" "net/url")func main() { var u url.Values u = url.Values{} u.Set("userId", "JAxxxx") u.Set("password", "123 456") fmt.Println(u.Encode())}$ go r...原创 2019-04-17 10:44:09 · 1220 阅读 · 0 评论 -
leetcode longest palindrome
https://blog.youkuaiyun.com/fareast_mzh/article/details/88543686* longestPalindrome.gopackage mainimport ( "fmt")func longestPalindrome(s string) string { if len(s) < 1 { return "" } var ...原创 2019-04-18 15:45:43 · 320 阅读 · 0 评论 -
golang 按行读文件 readline file_put_contents
* readline.gopackage mainimport ( "fmt" "os" "bufio" "io" "io/ioutil" "encoding/json" "strings")func fileForEachLine(path string, callback func(string)) { var f *os.File var err error...原创 2019-05-05 18:23:01 · 2488 阅读 · 0 评论 -
golang 解析xml文件
发送soap请求返回的xml* response.xml<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://dmdelivery.com/...原创 2019-03-18 10:57:14 · 1536 阅读 · 0 评论 -
golang 调用 网易云 滑块验证码 demo
用法PHP示例主要代码 session_start(); $verifier = new NECaptchaVerifier(YIDUN_CAPTCHA_ID, new SecretPair(YIDUN_CAPTCHA_SECRET_ID, YIDUN_CAPTCHA_SECRET_KEY)); $validate = $_POST['NECaptchaValidate']; // 获得...原创 2019-03-24 23:02:48 · 3228 阅读 · 2 评论 -
golang 按key字母顺序遍历map
golang maphttps://ashitani.jp/golangtips/tips_map.html* range.gopackage mainimport ( "fmt" "crypto/md5" "math/rand" "sort" "time")type MapEntryHandler func (string, string)// func p...原创 2019-03-24 22:13:54 · 3128 阅读 · 0 评论 -
atguigu.com chainblock 学习路线图
1. 前端- html + css + js- ES6- require.js AMD 模块化加载- webpack- Vue- npm + node + http- mongodb + mongoose- ajax + express + koa62. go语言- 基本数据类型 + 复合数据类型- 结构体和方法- 包和封装- OOP + int...原创 2018-10-04 23:14:13 · 429 阅读 · 0 评论 -
beego RESTFul路由
* go环境配置https://blog.youkuaiyun.com/fareast_mzh/article/details/81463777# native compiler darwin amd64export GOROOT=/usr/local/Cellar/go/1.10.3/libexecexport GOBIN=${GOROOT}/binexport GOPATH=/Volum...原创 2019-01-27 17:12:53 · 1186 阅读 · 0 评论 -
beego 的正则路由
* beego的restful路由https://blog.youkuaiyun.com/fareast_mzh/article/details/86667517* main.go// beego-route project main.gopackage mainimport ( "fmt" "github.com/astaxie/beego")type RegExpContr...原创 2019-01-27 17:51:23 · 1941 阅读 · 0 评论 -
gin orm 模板搬砖代码生成 字段批量赋值, 错误码switch case代码生成
* rows.php<?phpfunction fileForEachRow($path, $handler) { $handle = fopen($path, "r"); if (! $handle ) { return; } while (($buffer = fgets($handle, 1024) ) !== false) {...原创 2019-03-05 11:01:13 · 800 阅读 · 0 评论 -
php assoc => golang map php关联数组转换go map
* php assoc private static $_GRADE_NAME_TO_ID = array( 'a' => '03-2016', 'b' => '03-2017', 'zxc' => '03-2018', 'd' => '02-2016', 'e' => '02...原创 2019-03-06 11:46:52 · 533 阅读 · 0 评论 -
Golang 解决 golang.org/x/ 下包下载不下来的问题 GOPROXY
介绍:fleet 绑定了systemd 和etcd 到一个分布式init 系统,可以认为是systemd 的扩展,但是并不是机器级别的,而是集群级别的.,然后作者就想到了当初做PHP的时候,也有类似的项目,觉得golang也可以实现一个类似的书籍,暂且把书名定为《Go实战开发》.介绍:Go语言作为一个现代化的编程语言以及支持垃圾内存的自动回收特性(GC). 这篇文章主要介的是非内存资源的自动回收技术.介绍:Golang官方开源项目wiki主页,内容丰富.是学习golang的重要参考,文中还推荐了。原创 2019-02-27 10:43:33 · 5488 阅读 · 2 评论 -
golang 生成 6位随机 短信验证码 rand random
* getcode.gopackage mainimport ( "fmt" "math/rand" "strings" "time")func GenValidateCode(width int) string { numeric := [10]byte{0,1,2,3,4,5,6,7,8,9} r := len(numeric) rand.Seed(time.No...原创 2019-03-06 16:52:24 · 8856 阅读 · 3 评论 -
golang 数据类型转换
总结了golang中字符串和各种int类型之间的相互转换方式:string转成int:int, err := strconv.Atoi(string)string转成int64:int64, err := strconv.ParseInt(string, 10, 64)int转成string:string := strconv.Itoa(int)int64转成string:...转载 2019-03-14 17:29:15 · 410 阅读 · 0 评论 -
Golang RPC Thrift
进入 thrift_file 目录执行:$ thrift -out .. --gen go example.thrift,就会在 thrift_file 的同级目录下生成 golang 的包:example,其中 format_data-remote 是生成的测试代码可以不用特别关注。的源码,解压后进入:thrift-0.10.0/compiler/cpp 目录执行如下命令完成编译后。,下载完成后改名为:thrift.exe 并将其放入到系统环境变量下即可使用。还需要import "context"原创 2019-03-15 09:41:27 · 465 阅读 · 1 评论 -
golang string byte[] slice 数组/字符串 相互转化 以及与javascript对比
* bytes.gopackage mainimport "fmt"func main() { // var str = "hello" str := "hello" // var a = str.split('').map(function(c) {return c.charCodeAt(0)}) data := []byte(str) fmt.Println(data)...原创 2019-03-11 17:27:42 · 1672 阅读 · 0 评论 -
golang解析json文件
* gopher.json{ "name": "Gopher", "title": "programmer", "contact": { "home":"415.333.3333", "cell":"415.555.5555" }}* gopher.gopackage mainimport ( "encoding/json" "...原创 2019-03-20 10:37:31 · 4334 阅读 · 0 评论 -
golang 日期相关的方法
* 时间戳转换格式字符串 time.Unix(1552699194, 0).Format("2006-01-02 15:04:05")2006-01-02 15:04:05 这个日期是固定的不能改!http://47.93.27.106:6060/pkg/time/#Time.Format* 当前时间戳 s time.Now().Unix()...原创 2019-03-16 09:21:00 · 295 阅读 · 0 评论 -
golang http post 查询短信平台余额, SMS短信接口
* mongate.goconst SMS_ASMX = "http://???.???.??:???:8016/MWGate/wmgw.asmx" // 梦网请求url前缀const SMS_HOST = "???.???.??.???:8016" // 梦网hostconst SMS_USERID = "JA????" // 梦网充值账号const SMS_PASSWO...原创 2019-03-16 14:07:12 · 634 阅读 · 0 评论 -
golang DP LCS 最长公共子序列的长度
https://medium.com/@codingfreak/top-50-dynamic-programming-practice-problems-4208fed71aa31. 暴力递归* LCS.gopackage mainimport ( "fmt")func LCSLength(x []byte, y []byte, m int, n int) int {...原创 2019-03-17 22:20:17 · 1292 阅读 · 0 评论 -
golang 字符串拼接 数组转化为字符串 Array => String strings.Join Array.prototype.join implode
* strings.join// Join concatenates the elements of a to create a single string. The separator string// sep is placed between elements in the resulting string.func Join(a []string, sep string) str...原创 2018-12-01 15:58:10 · 4360 阅读 · 0 评论