[Go] golang使用github里的imap类库
1.在windows系统下,需要首先定义两个环境变量GOPATH和GOROOT, GOPATH是第三方类库的代码目录 , GOROOT是go的安装目录

2.按照我的定义 , 进入这个目录D:\golang\code\src\github.com\emersion , 使用git 更新代码
git clone https://github.com/emersion/go-imap.git
git clone https://github.com/emersion/go-sasl.git
package main import (
"github.com/emersion/go-imap"
"github.com/emersion/go-imap/client"
"log"
) const (
server = "imap.sina.net:993"
username = "shihan@sopans.com"
password = "xxxx"
) func main() {
var c *client.Client
var err error
log.Println("Connecting to server...")
c, err = client.DialTLS(server, nil)
//连接失败报错
if err != nil {
log.Fatal(err)
}
log.Println("Connected")
//登陆
if err := c.Login(username, password); err != nil {
log.Fatal(err)
}
log.Println("Logged in")
mailboxes := make(chan *imap.MailboxInfo, 20)
go func() {
c.List("", "*", mailboxes)
}()
//列取邮件夹
for m := range mailboxes { mbox, err := c.Select(m.Name, false)
if err != nil {
log.Fatal(err)
}
to := mbox.Messages
log.Printf("%s : %d", m.Name, to)
}
}

[Go] golang使用github里的imap类库的更多相关文章
- golang实现php里的serialize()和unserialize()序列和反序列方法
Golang 实现 PHP里的 serialize() . unserialize() 安装 go get -u github.com/techleeone/gophp/serialize 用法 pa ...
- 【问题解决方案】本地代码文件上传到GitHub里中文乱码问题
刚刚学完Git并试着上传了我的化石Java代码到远程库,表面一切和谐,然而.. 真让人大惊失色.. step1-检查浏览器是否是utf-8(谷歌默认是) step2-在本地编辑器设置 (按理说,not ...
- jenkins~管道Pipeline里使用公用类库
Pipeline使用了groovy语法,同时可以使用所有jenkins插件在groovy里进行调用,可以说通过UI可以实现的功能使用pipeline也可以实现,这一点我在上一篇文章里已经说明,今天主要 ...
- 关于github里readme编辑的方法
实验室的老师昨天改完论文发我后,说按照例子改.于是才发现github里readme编辑满满的极客思维. 看了一下csdn给的教程 https://blog.csdn.net/Kaitiren/arti ...
- github里的readme.md
在github里如何写readme.md https://www.cnblogs.com/guchunli/p/6371040.html----------------------> READM ...
- github里的gist是什么意思
在有关github的客户端中经常遇到gist这个词,如Gists->My Gists,Public Gists. 字典里解释gist为(发言.谈话或文章的)主旨,要点.百度百科的解释太恶心,我不 ...
- 用Git将项目发布在GitHub里
转载自http://blog.csdn.net/u011572517/article/details/50537407,个人加了一些注意事项和解释. githud是一个程序员以后成长都会使用到的,先不 ...
- 【问题解决方案】下载GitHub里的单个文件
背景:在不把整个项目弄下来的情况下 步骤:raw --> 右击 --> 链接另存为... 参考:如何用浏览器从 github 上下载某项目中的单个文本文件
- github里如何删除一个repository仓库
高手请绕行,新手往下走. 作为一个刚接触github(https://github.com/)的新手,除了感叹开源的丰富和强大之外,自己肯定也想试用一下,因此申请帐号神马的.今天自己创建一个Repos ...
随机推荐
- [LeetCode] Rectangle Overlap 矩形重叠
A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bot ...
- FCC(ES6写法)Pairwise
举个例子:有一个能力数组[7,9,11,13,15],按照最佳组合值为20来计算,只有7+13和9+11两种组合.而7在数组的索引为0,13在数组的索引为3,9在数组的索引为1,11在数组的索引为2. ...
- Java线程和进程相关面试题与答案总结
有几天没有写一写博客了,今天就带给大家一些面试题和参考答案吧! 这些都是上海尚学堂Java培训的学员去面试时遇到的问题,今天总结出来的是Java线程相关类的面试题.把参考答案和解析也发布出来,供大家学 ...
- Python科学计算基础包-Numpy
一.Numpy概念 Numpy(Numerical Python的简称)是Python科学计算的基础包.它提供了以下功能: 快速高效的多维数组对象ndarray. 用于对数组执行元素级计算以及直接对数 ...
- [Java]LeetCode138. 复制带随机指针的链表 | Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point t ...
- [Swift]LeetCode600. 不含连续1的非负整数 | Non-negative Integers without Consecutive Ones
Given a positive integer n, find the number of non-negativeintegers less than or equal to n, whose b ...
- [Swift]LeetCode957. N天后的牢房 | Prison Cells After N Days
There are 8 prison cells in a row, and each cell is either occupied or vacant. Each day, whether the ...
- 【Redis篇】Redis集群安装与初始
一.前述 本文将单台节点不同端口模拟集群方式. 二.具体搭建 前提是安装好redis具体可参考http://www.cnblogs.com/LHWorldBlog/p/8463269.html 1 ...
- Python内置函数(31)——id
英文文档: id(object) Return the “identity” of an object. This is an integer which is guaranteed to be un ...
- C# for Python(Nugut Iron包)
cInronPython是一种在.NET和Mono上实现的Python语言,使用InronPython就可以在.NET环境中调用Python代码 安装InronPython Python: port ...