windows 7 64位系统,golang 版本1.2
go默认安装在c:\Go
GOPATH为c:\Go_path
测试alphazero/Go-Redis,过程如下
文件位置c:\go_test\re.go,代码如下:
package main
import (
"bufio"
"fmt"
"github.com/alphazero/Go-Redis/redis"
"log"
"os"
)
func main() {
spec := redis.DefaultSpec().Db(13)
client, e := redis.NewSynchClientWithSpec(spec)
if e != nil {
log.Println("failed to create the client", e)
return
}
key := "examples/hello/user.name"
value, e := client.Get(key)
if e != nil {
log.Println("error on Get", e)
return
}
if value == nil {
fmt.Printf("\nHello, don't believe we've met before!\nYour name? ")
reader := bufio.NewReader(os.Stdin)
user, _ := reader.ReadString(byte('\n'))
if len(user) > 1 {
user = user[0 : len(user)-1]
value = []byte(user)
client.Set(key, value)
} else {
fmt.Printf("vafanculo!\n")
return
}
}
fmt.Printf("Hey, ciao %s!\n", fmt.Sprintf("%s", value))
}
c:\go_path目录下有pkg,src,bin,3个目录
首先获取redis包,执行如下命令
go get github.com/alphazero/Go-Redis/redis
获取成功,如图,
C:\Go_path\pkg\windows_amd64\github.com\alphazero目录生成了Go-Redis.a
cmd进入c:\go_test\,执行
go run re.go
提示
c:\go_test>go run re.go
re.go:6:2: cannot find package "github.com/alphazero/Go-Redis/redis" in any of:
C:\Go\src\pkg\github.com\alphazero\Go-Redis\redis (from $GOROOT)
C:\Go_path\src\github.com\alphazero\Go-Redis\redis (from $GOPATH)
C:\Go_path\src\github.com\alphazero\Go-Redis\目录确实有redis.go文件的
一直编译不成功,请问这个是什么情况?
— —! Faham, ia mengandungi direktori dan bukannya fail, jadi perpustakaan yang diimport mestilah
Tetapi laporkan ini
Mungkin ini adalah had versi, saya akan mencuba pustaka redis yang lain
================================ update lagi =====
Mengubah perpustakaan github.com/fzzy/radix/redis dan menyusunnya dengan kod ujiannya.
Pelbagai masalah pada tingkap...