Skip to content

Commit

Permalink
Renamed Kaitai_IO -> IO_ as per PR discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyCat committed Mar 30, 2024
1 parent 9f594fd commit af7c638
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,4 @@ issues:
# excluded by default patterns execute `golangci-lint run --help`
exclude:
- Using the variable on range scope `tt` in function literal
- "var-naming: don't use underscores in Go names; method Kaitai_IO should be KaitaiIO"
- "ST1003: should not use underscores in Go names; method Kaitai_IO should be KaitaiIO"
- "var-naming: don't use underscores in Go names; method IO_ should be IO"
10 changes: 5 additions & 5 deletions kaitai/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package kaitai
// Struct is the common interface guaranteed to be implemented by all types generated by
// Kaitai Struct compiler.
type Struct interface {
// Kaitai_IO returns the stream object associated with the struct.
// IO_ returns the stream object associated with the struct.
//
// This is deliberately named with a `Kaitai_` prefix and underscore to avoid conflicts
// with other methods that may result from the attributes in Kaitai Struct type, e.g.
// is a user will define attribute `i_o` this will conflict with the method `IO()`.
Kaitai_IO() *Stream
// This is deliberately named with a `_` suffix to avoid conflicts with other methods
// that may result from the attributes in Kaitai Struct type, e.g. if a user will define
// attribute `i_o` this will conflict with the method `IO()`.
IO_() *Stream
}
6 changes: 3 additions & 3 deletions kaitai/struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type oneStruct struct {
_io *Stream
}

func (s *oneStruct) Kaitai_IO() *Stream {
func (s *oneStruct) IO_() *Stream {
return s._io
}

Expand All @@ -22,13 +22,13 @@ type twoStruct struct {
_io *Stream
}

func (s *twoStruct) Kaitai_IO() *Stream {
func (s *twoStruct) IO_() *Stream {
return s._io
}

func WorkWithStruct(t *testing.T, s Struct, expectedSize int) {
t.Helper()
actualSize, err := s.Kaitai_IO().Size()
actualSize, err := s.IO_().Size()
assert.Nil(t, err)
assert.Equal(t, actualSize, int64(expectedSize))
}
Expand Down

0 comments on commit af7c638

Please sign in to comment.