素胚勾勒不出你
我不认为有直接的功能,但实现一个 usingio.LimitReader很简单。func ReadLimitedLine(r io.Reader, delim byte, max int64) ([]byte, error) { l, err := bufio.NewReader(io.LimitReader(r, max)).ReadBytes(delim) if err != nil && err != io.EOF { return nil, err } // ReadBytes includes the delimiter in return value return bytes.TrimSuffix(l, []byte{delim}), nil}