Source File
state.go
Belonging Package
github.com/pierrec/lz4/v4
package lz4import ()//go:generate go run golang.org/x/tools/cmd/stringer -type=aState -output state_gen.goconst (noState aState = iota // uninitialized readererrorState // unrecoverable error encounterednewState // instantiated objectreadState // reading datawriteState // writing dataclosedState // all done)type (aState uint8_State struct {states []aStatestate aStateerr error})func ( *_State) ( []aState) {.states =.state = [0]}func ( *_State) () {.state = .states[0].err = nil}// next sets the state to the next one unless it is passed a non nil error.// It returns whether or not it is in error.func ( *_State) ( error) bool {if != nil {.err = fmt.Errorf("%s: %w", .state, ).state = errorStatereturn true}.state = .states[.state]return false}// nextd is like next but for defers.func ( *_State) ( *error) bool {return != nil && .next(*)}// check sets s in error if not already in error and if the error is not nil or io.EOF,func ( *_State) ( *error) {if .state == errorState || == nil {return}if := *; != nil {.err = fmt.Errorf("%w[%s]", , .state)if !errors.Is(, io.EOF) {.state = errorState}}}func ( *_State) () error {.state = errorState.err = fmt.Errorf("%w[%s]", lz4errors.ErrInternalUnhandledState, .state)return .err}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |