《Go并发编程实战》函数封装的调用

2017-01-13  本文已影响49人  大雁儿

go语言的封装相比其他语言简单明了,特别是书中给出的例子


简单明了,即便是像我这样的新手看了也是一目了然,可是程序虽然简单了,不会调用,所以就傻逼了,反正现在为止,我还是不会调用,本文只作为问题记录。
如果有幸被go语言学习者看到,会使用的请在留言告诉我,我会默默感谢你的,并修改此文造福更多的初学者。
如果后期随着技能的get我学会了怎么调用,也会来这边修改文章,放上解决办法滴,一方面是记录自己的学习过程,另一方面也能同时分享给大家。
学习调用的经历


为了自己下一次方便复制,黏上代码,为了了解怎么输入代码也耗了点时间,这一点应该学学CSDN,简书这样一点都不智能

package main
import "fmt"

//type Encipher func(plaintext string)[]byte
//func GenEncryptionFunc(encrypt Encipher)func(string)(ciphertext  string)  {
    // return func(plaintext string)  string{
    //    return fmt.Sprintf("%x",encrypt(plaintext))
// }

//}func Encipher(plaintext string)[]byte  {  
       return []byte(plaintext)
}

func GenEncryptionFunc(ciphertext string) string {   
      return string(Encipher(ciphertext))
}
func main()  {   
      //res:= Encipher("learning")   
     //result:=GenEncryptionFunc(Encipher("learning"))    
      //fmt.Printf("%x",GenEncryptionFunc(Encipher("learning")))  
     //fmt.Printf("res=%s",res)   
    fmt.Println("res1:",Encipher("learning"))   
    fmt.Println("\nres2:",GenEncryptionFunc("learning"))
}
上一篇 下一篇

猜你喜欢

热点阅读