go语言安装第三方程序包
来源:互联网 发布:ansible windows 编辑:程序博客网 时间:2024/06/05 01:14
这里拿我最近正在看的一个源码举例。
环境: win10+jetBrains Gogland+git bash客户端
安装第三方go-cache程序包
源码的地址
https://github.com/patrickmn/go-cache
Go 语言实现的一个内存中的缓存框架,实现 Key-Value 的序列存储,适用于单台机器应用程序。
安装前需要两个前提条件:
- 具备GOPATH环境变量,这个一般只要你安装好了go语言的IDE环境都应该有的。
- 安装一个git客户端(我的是windows环境,用的是git bash)
安装过程很简单,一条指令,
pony@DESKTOP-17T9AJU MINGW64 ~$ go get github.com/patrickmn/go-cache
安装完成没有任何的提示,为了确保成功我们可以去GOPATH环境变量对应的目录看下是否有安装文件。首先会在src目录下存在一个go-cache的源码目录,然后pkg目录下有个go-cache.a库文件。
测试
安装完成了,测试下。新建一个文件,
package mainimport ( "github.com/patrickmn/go-cache" // 从环境变量:%goPath% 中定义的路径去查找第三方类库 "fmt" "time")func main() { // Create a cache with a default expiration time of 5 minutes, and which // purges expired items every 10 minutes c := cache.New(5*time.Minute, 10*time.Minute) // Set the value of the key "foo" to "bar", with the default expiration time c.Set("foo", "bar", cache.DefaultExpiration) // Set the value of the key "baz" to 42, with no expiration time // (the item won't be removed until it is re-set, or removed using // c.Delete("baz") c.Set("baz", 42, cache.NoExpiration) // Get the string associated with the key "foo" from the cache foo, found := c.Get("foo") if found { fmt.Println(foo) }}
运行,
barProcess finished with exit code 0
阅读全文
0 0
- go语言安装第三方程序包
- Go语言安装第三方库
- 【go语言 安装第三方包】阿里云下go语言如何装第三方包?
- 安装go第三方库
- 安装 Go 第三方包 go-sqlite3
- go第三方库的安装例子
- 关于go的第三方包go-sqlite3的安装
- go 语言第三方库parallel的并行使用
- go get安装第三方包的前提条件和步骤
- Go安装各种第三方库,包命令
- go get安装第三方包的前提条件和步骤
- Go Get安装一些第三方库-网络问题
- android 获取第三方应用程序包名并启动
- android第三方程序包问题——NoClassDefFoundError
- C++第三方程序包在不同操作系统下的使用
- android 获取第三方应用程序包名并启动
- android 获取第三方应用程序包名并启动
- go语言 map转成struct结构(调用第三方包)
- 事件深入应用一
- 【Real-Time Rendering 3rd】开坑的序章
- 大数据量下高并发同步的讲解
- 基于Android真实项目教你一步一步搭建架构1 -- 概述
- Java基础加强-读取配置文件和内省
- go语言安装第三方程序包
- kafka集群编程指南
- 二维数组中的查找
- 【TypeScript学习笔记】使用ByteArray进行zlib.js压缩compress和解压uncompress
- poj 3406 (勒让德定理)
- URL访问过程
- Windows 10更新率暴涨:因勒索病毒全球爆发
- java Random类
- DOM的使用方法以及属性