- 博客(9)
- 收藏
- 关注
原创 Go语言监控文件变化小程序.
package mainimport ( "log" "github.com/go-fsnotify/fsnotify")func main() { watcher, err := fsnotify.NewWatcher() if err != nil { log.Fatal(err) } defer watcher.Close() done := make(chan
2015-09-29 16:41:23 7562
原创 Go语言自己实现的异步小log程序.
slog.gopackage slogimport ( "errors" "fmt" "os" "strings" "time")type Logger struct { console bool warn bool info bool tformat func() string file chan string}func NewLog(l
2015-09-28 11:47:19 2685 1
原创 Go语言简单实现FTP协议.
package ftpimport ( "errors" "fmt" "io" "net" "os" "strconv" "strings")type Ftp struct { con net.Conn ip string}func NewFtp(ip string) (*Ftp, error) { buf := make([]byte, 1024) con
2015-09-24 13:13:42 5338 4
原创 GO1.5.1使用ssh,与Linux交互.带终端
package mainimport ( "golang.org/x/crypto/ssh" "log" "os")type Rw struct{}func main() { client("root", "123456", "127.0.0.1:5506")}func client(user, passwd, ip string) { config := &ssh.C
2015-09-14 13:09:25 3509 2
原创 Go1.5从文件读取密码,然后到远端下载文件的小实例.(通过sftp协议下载)
package mainimport ( "bufio" "fmt" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" "io" "log" "net" "os" "path/filepath" "regexp" "sftp" "strings")func main() { if len(os.A
2015-09-11 11:40:05 1246
原创 go-xorm使用mssql的小实例
package mainimport ( "fmt" "os" "time" "github.com/go-xorm/core" "github.com/go-xorm/xorm" _ "github.com/lunny/godbc")type NxServerState struct { ID int `xorm:"pk not nu
2015-09-07 11:49:40 3986
原创 godbc中使用mssql的小实例
package xormimport ( "database/sql" "testing" _ "github.com/lunny/godbc")const mssqlConnStr = "driver={SQL Server};Server=192.168.20.135;Database=xorm_test; uid=sa; pwd=1234;"func newMssqlE
2015-09-07 08:40:30 1079
原创 go1.5 动态密码,最简单的实现使用hmac加密
package mainimport ( "crypto/md5" "fmt" "strconv" "strings" "time")func main() { for i := 0; i < 20; i++ { M := md5.New() M.Write([]byte(fmt.Sprint(time.Now().Unix() - (time.Now().Unix(
2015-09-02 15:11:43 2449
原创 Go语言fmt.Printf的使用
Fmt包import "fmt"简介 ▾Package fmt包含有格式化I/O函数,类似于C语言的printf和scanf。格式字符串的规则来源于C但更简单一些。输出格式:一般:%v 基本格式的值。当输出结构体时,扩展标志(%+v)添加成员的名字。the value in a default format. when printing structs,
2015-09-02 13:33:30 5735
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人