chore: use range

This commit is contained in:
andig 2024-10-23 16:04:40 +02:00
parent 3d463d40d4
commit b86f3bf183
4 changed files with 4 additions and 4 deletions

View file

@ -36,7 +36,7 @@ func (d *Connection) ExecCmd(cmd string, res interface{}) error {
// encode command message
buf := bytes.NewBuffer([]byte{0, 0, 0, 0})
var key byte = 171 // initialization vector
for i := 0; i < len(cmd); i++ {
for i := range cmd {
key ^= cmd[i]
_ = buf.WriteByte(key)
}

View file

@ -19,7 +19,7 @@ type handler struct {
func bytesAsUint16(b []byte) []uint16 {
u := make([]uint16, 0, len(b)/2)
for i := 0; i < len(b)/2; i++ {
for i := range len(b) / 2 {
u = append(u, binary.BigEndian.Uint16(b[2*i:]))
}
return u

View file

@ -126,7 +126,7 @@ func (t *Tariff) priceRates() (api.Rates, error) {
res := make(api.Rates, 48)
start := now.BeginningOfHour()
for i := 0; i < len(res); i++ {
for i := range res {
slot := start.Add(time.Duration(i) * time.Hour)
res[i] = api.Rate{
Start: slot,

View file

@ -399,7 +399,7 @@ func (v *Identity) stamp() (string, error) {
}
enc := make([]byte, 0, 50)
for i := 0; i < len(cfb); i++ {
for i := range cfb {
enc = append(enc, cfb[i]^raw[i])
}