自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Simon的博客

专注于互联网后台架构开发

  • 博客(11)
  • 收藏
  • 关注

原创 golang项目莫名的问题

# command-line-argumentscannot open file C:\Go\pkg\windows_amd64/user-service/userprofile/dao.a: open C:\Go\pkg\windows_amd64/user-service/userprofile/dao.a: The system cannot find the path specifie...

2018-03-29 19:43:15 1611 1

原创 go get无法下载git代码

simon@ubuntu:~/git/src/github.com$ go get github.com/grpc/grpcpackage github.com/grpc/grpc: cannot download, $GOPATH must not be set to $GOROOT. For more details see: go help gopathsimon@ubuntu:~/gi...

2018-03-29 15:54:24 3907

原创 golang构建htpp服务

1、简单实现serverpackage mainimport ( "flag" "net/http")func main() { host := flag.String("host", "127.0.0.1", "listen host") port := flag.String("port", "8080", &quo

2018-03-29 11:24:03 334

原创 golang protobuf 的序列化和反序列化

1、通过proto文件生成go代码hello.protosyntax = "proto3";package prototest;message Test { int32 num = 1; string msf = 2;}hello.pb.go// Code generated by protoc-gen-go. DO NOT EDIT.// source...

2018-03-28 21:26:11 9816

原创 Ubuntu配置golang的protobuf的go代码生成环境

1、下载gitsudo apt-get install git2、下载go语言的protobufgit clone https://github.com/golang/protobuf sudo apt-get install protobuf-compiler3、配置GOPATHvim ~/.bashrc source ~/.bashrc4、安装prot...

2018-03-27 20:03:38 1199

原创 Windows下安装Ubuntu虚拟机并配置go环境

安装虚拟机1、下载VMware,Ubuntu的iso安装包 2、打开bios中的VT-X、VT-D选项,VT就是虚拟机的意思 3、新建虚拟机 4、安装VMware tools。点击菜单虚拟机->安装VMWare tools,Ubuntu中出下载一个压缩包,解压出现文件夹vmware-tools-distrib,运行vmware-install.pl文件./vmware-instal...

2018-03-25 11:30:52 1220

原创 go语言struct中的tag

一句话总结:方便通过tag获取struct的成员变量为什么要有taggo语言中命名都是推荐都是用驼峰方式,但是由于实际项目中经常需要和其它的系统进行数据交互,这个时候如果用属性名来作为键值可能不一定会符合项目要求。如代码中对象的结构体的成员变量和数据库表中的列名的映射关系的建立是通过struct Tag来实现的。如何获取tag直接上实例吧package mainimpo...

2018-03-22 22:12:30 1711

原创 yml文件解析

主要使用了开源组件github.com/uber-go/config直接上实例吧,这里的环境变量及具体yml文件路径都是配置过的。test.yml文件yml: desc: we are testing yml代码package mainimport ( "flag" "fmt" "github.com/uber-go/config" "os" "strings")var (...

2018-03-22 21:45:43 1650

原创 正向索引(forward index)和反向索引(inverted index)

正向索引(forward index)和反向索引(inverted index)一句话总结通过A搜索B是正向索引,那么反过来通过B去搜索A就是反向索引。是不是很简单。实例说明先看个例子吧。 我们搜索正向索引,这4个字会被拆分为“正向索引”、“向索引”、“索引”,分别搜索对应的文档的标题和内容有该关键字的网页,这就是反向索引。 为何不用正向索引呢,我们看看正向索引文档1->正排索引、倒排索引文...

2018-03-22 21:20:42 4811

原创 go语言“依赖注入”

一句话总结:解耦组件之间的依赖关系,避免手动配置每个组件的依赖关系。下面实例来自:https://godoc.org/github.com/facebookgo/injectpackage mainimport ( "fmt" "net/http" "os" "github.com/facebookgo/inject")// Our Awesome Applic...

2018-03-18 19:17:27 1207

原创 go语言中flag的用法——参数解析

一句话总结:用于参数解析package mainimport ( "flag" "fmt")var ( configPath = flag.String("configPath", "project/config/config.xml", "configPath flag"))func main() { flag.Parse() fmt.Println(*configPath)}我们获取配置文件有...

2018-03-18 18:22:44 5973

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除