gob的一次低级错误
package main

import (
	"bytes"
	"encoding/gob"
	"fmt"
	"net"
)

type User struct {
	Name, Pass string
}
type User2 struct {
	qwe string
	xsa string
}
func main() {
	var xxs =new(User2)
	Load(xxs)
	fmt.Println(xxs)
}

func Load(object interface{}) (){
	Conn, _ := net.Dial("tcp", "127.0.0.1:1234")
	tmp:=make([]byte,1024)
	len1,_:=Conn.Read(tmp)
	tmp=tmp[:len1]
	a:=bytes.NewBuffer(tmp)
	decoder := gob.NewDecoder(a)
	decoder.Decode(object)

	Conn.Close()
}

因为user2的成员没有大写,导致结果不正常

type User2 struct {
	qwe string
	xsa string
}

改成这样就行啦

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇