有哪些简单的项目可以学习
看了一个月的书了,打算学习项目,不知道从哪里下手?? 新手求大神指...阅读全文
看了一个月的书了,打算学习项目,不知道从哪里下手?? 新手求大神指...阅读全文
func XorEncodeStr(msg, key string) string { ml := len(msg) kl := len(key) pwd := "" for i := 0; i < ml; i++ { pwd += (string((key[i%kl]) ^ (msg[i]))) } return pwd}func XorDecodeStr(msg, key string) string { ml := len(msg) kl := len(key) pwd := "" for i := 0; i < ml; i++ { pwd += (string(((msg[i]) ^ key[i%kl]))) } return pwd} 使用方法,传入msg和key即可,开始百度了很...阅读全文
package main import ( "encoding/json" "fmt" ) type detail struct { Ip string NetType string Start int End int } type Config struct { Host string Nodes map[string]detail } func main() { var config Config file :=...阅读全文
go作为移动端的后台可行吗?前面是安卓的话,望高人指点...阅读全文
小白问个入门问题,你所在的公司做go开发是直接在linux,还是在window系统上,求指...阅读全文
今天在看martini的源码,其中有这个函数: ```go func (m *Martini) RunOnAddr(addr string) { logger := m.Injector.Get(reflect.TypeOf(m.logger)).Interface().(*log.Logger) logger.Printf("listening on %s (%s)\n", addr, Env) logger.Fatalln(http.ListenAndServe(addr, m)) } ``` 里面获取logger的方式为什么不用m.logger,非要采用Injector方式,是性能的原因吗?请大家指...阅读全文
package main import ( "net" ) type byteArray []byte func clientFactory(client net.Conn) { //buff := make([]byte, 100) client.Write(byteArray("HTTP/1.1 200 OK\n\nHello World!!")) println("send message!!") client.Close() } func main() { if ln, err := net.Lis...阅读全文
菜鸟求教,一个简单无限循环代码,但为什么输入bye,却无法结束呢? package main import( "bufio" "fmt" "os" "strings" ) func main(){ inputReader := bufio.NewReader(os.Stdin) fmt.Println("Please input your name:") input,err := inputReader.ReadString('\n') if err!=nil{ fmt.Printf("An error occurred :%s\n", err) os.Exit(1) }else{ name := inp...阅读全文
运行环境windows,使用了os.remove和调用dos命令,都没有把exe删掉,有大佬指点一下...阅读全文
  ...阅读全文
package main import ( "fmt" ) func bbb(rch chan string) { a := []string{"aaaa", "bbbbb", "ccccc"} for _, b := range a { rch <- b } } func aaa(rch <-chan string, ch chan<- bool) { for m := range rch { fmt.Println(m) } ch <- false } func main() { ch := make(chan bool) rch := make(chan string) go bbb(rch) go aaa(rch, ch) <-ch ...阅读全文
```go // performQueries tests the resource pool of connections. func performQueries(query int, p *pool.Pool) { // Acquire a connection from the pool. conn, err := p.Acquire() if err != nil { log.Println(err) return } // Release the connection back to the pool. defer p.Release(conn) // Wait to simulate a query response. ti...阅读全文
想问下怎么用下图查出的这些属性计算cpu的利用率?在线等,急急急!!!  ...阅读全文
func readMaze(fileName string) [][]int{ file, err := os.Open(fileName) if err != nil{ panic(err) } var row, col int fmt.Fscanf(file, "%d %d", &row, &col) maze := make([][]int, row) for i := range maze { maze[i] = make([]int, col) for j := range maze[i] { fmt.Fscanf(file, "%d", &maze[i][j]) } } return maze } func main() { maze := readMaze("src/maze/...阅读全文