diff --git a/.golangci.yml b/.golangci.yml index 9d5b4e2..fae3138 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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" diff --git a/kaitai/struct.go b/kaitai/struct.go index 0facd02..9a49878 100644 --- a/kaitai/struct.go +++ b/kaitai/struct.go @@ -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 } diff --git a/kaitai/struct_test.go b/kaitai/struct_test.go index 250fc02..7cdf9c0 100644 --- a/kaitai/struct_test.go +++ b/kaitai/struct_test.go @@ -13,7 +13,7 @@ type oneStruct struct { _io *Stream } -func (s *oneStruct) Kaitai_IO() *Stream { +func (s *oneStruct) IO_() *Stream { return s._io } @@ -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)) }