@@ -10,27 +10,27 @@ import (
1010 "github.com/Sn0wo2/QuickNote/pkg/compress"
1111)
1212
13- // magicHeader First 2 bytes of SHA-256 hash of "QuickNote"
14- var magicHeader = [... ]byte {0x34 , 0x19 }
15-
1613const (
1714 magicVersion = 1
1815 fieldTitle = 1
1916 fieldContent = 2
2017)
2118
19+ // magicHeader First 2 bytes of SHA-256 hash of "QuickNote"
20+ var magicHeader = [... ]byte {0x34 , 0x19 }
21+
2222func (n * Note ) Encode () error {
2323 if n == nil {
2424 return errors .New ("nil note" )
2525 }
2626
2727 buf := bytes .NewBuffer (magicHeader [:])
28-
2928 buf .WriteByte (magicVersion )
3029
3130 writeField := func (id byte , data []byte ) {
3231 buf .WriteByte (id )
33- _ = binary .Write (buf , binary .LittleEndian , len (data )) //nolint:staticcheck
32+ //nolint:gosec
33+ _ = binary .Write (buf , binary .LittleEndian , uint32 (len (data )))
3434 buf .Write (data )
3535 }
3636
@@ -85,7 +85,6 @@ func (n *Note) Decode(data []byte) error {
8585 return fmt .Errorf ("read field %d length: %w" , id , err )
8686 }
8787
88- // read length b4 field
8988 value := make ([]byte , binary .LittleEndian .Uint32 (buf ))
9089 if _ , err = io .ReadFull (r , value ); err != nil {
9190 return fmt .Errorf ("read field %d: %w" , id , err )
0 commit comments