ruyi789
ruyi789
``` local __json_object = {__json_object = function() end} function json.newObject() return setmetatable({}, __json_object) end ``` parse_object ``` local function parse_object(str, i) local res = json.newObject() ``` encode_table ``` local t...
这个包满足我的,因为很小,而且是官方维护。唯一不足的地方大多数人没法用它,因为不会Read。 var c *websocket.Conn var buf bytes.Buffer b := make([]byte, 1024) for { n, err := c.Read(b) if n > 0 { buf.Write(b[:n]) } else if err != nil {...
Misuse is undesirable, disabling is even worse, you want to change you maintain that package (go-json), that doesn't solve it?
If you are sceptical about Writer, then panic, no need to return, just give feedback to the developer ``` func WriteTryPanic(w io.Writer, p []byte) (n int, err error) { n,...
If you do encounter a defective Writer, is it completely safe by checking ErrShortWrite? No. The return values are all accurate, and the defect is actually still there, which is...
Return n is some Write after the need to try again Write, if you only need to ensure that n is complete, there is no need to judge again err....
``` func test1() (b []byte,err error ){ b, err = os.ReadFile("./test1") //if-simplify if l:=len(b);l==0||l>65536@nil,fmt.Errorf("bad data:%d",l) else b==[]byte("bad")@nil,fmt.Errorf("bad file:%d",l) else if err==io.ErrUnexpectedEOF{ //fmt.Println(string(b)) //panic(fmt.Errorf("ErrUnexpectedEOF:%d",l)) return nil,err } else b,err==io.EOF@nil else nil,err!...