Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add setters for struct fields #98

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-02-23T16:13:22Z by kres latest.
# Generated on 2024-07-15T11:59:50Z by kres ac94478.

codecov:
require_ci_to_pass: false
Expand All @@ -9,7 +9,7 @@ coverage:
status:
project:
default:
target: 40%
target: 35%
threshold: 0.5%
base: auto
if_ci_failed: success
Expand Down
2 changes: 1 addition & 1 deletion .kres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
---
kind: service.CodeCov
spec:
targetThreshold: 40
targetThreshold: 35
---
kind: auto.CustomSteps
spec:
Expand Down
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# syntax = docker/dockerfile-upstream:1.7.1-labs
# syntax = docker/dockerfile-upstream:1.9.0-labs

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-05-29T13:52:46Z by kres a914cae.
# Generated on 2024-07-15T11:59:50Z by kres ac94478.

ARG TOOLCHAIN

Expand All @@ -24,14 +24,14 @@ zpool create -f -R /tmp/zfs zroot1 /tmp/zfs.img

# build tools
FROM --platform=${BUILDPLATFORM} toolchain AS tools
ENV GO111MODULE on
ENV GO111MODULE=on
ARG CGO_ENABLED
ENV CGO_ENABLED ${CGO_ENABLED}
ENV CGO_ENABLED=${CGO_ENABLED}
ARG GOTOOLCHAIN
ENV GOTOOLCHAIN ${GOTOOLCHAIN}
ENV GOTOOLCHAIN=${GOTOOLCHAIN}
ARG GOEXPERIMENT
ENV GOEXPERIMENT ${GOEXPERIMENT}
ENV GOPATH /go
ENV GOEXPERIMENT=${GOEXPERIMENT}
ENV GOPATH=/go
ARG DEEPCOPY_VERSION
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/siderolabs/deep-copy@${DEEPCOPY_VERSION} \
&& mv /go/bin/deep-copy /bin/deep-copy
Expand Down Expand Up @@ -68,7 +68,7 @@ RUN FILES="$(gofumpt -l .)" && test -z "${FILES}" || (echo -e "Source code is no
FROM base AS lint-golangci-lint
WORKDIR /src
COPY .golangci.yml .
ENV GOGC 50
ENV GOGC=50
RUN golangci-lint config verify --config .golangci.yml
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/root/.cache/golangci-lint --mount=type=cache,target=/go/pkg golangci-lint run --config .golangci.yml

Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-06-03T15:33:50Z by kres f292767.
# Generated on 2024-07-15T11:59:50Z by kres ac94478.

# common variables

Expand All @@ -17,15 +17,15 @@ WITH_RACE ?= false
REGISTRY ?= ghcr.io
USERNAME ?= siderolabs
REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME)
PROTOBUF_GO_VERSION ?= 1.34.1
PROTOBUF_GO_VERSION ?= 1.34.2
GRPC_GO_VERSION ?= 1.4.0
GRPC_GATEWAY_VERSION ?= 2.20.0
VTPROTOBUF_VERSION ?= 0.6.0
GOIMPORTS_VERSION ?= 0.21.0
GOIMPORTS_VERSION ?= 0.23.0
DEEPCOPY_VERSION ?= v0.5.6
GOLANGCILINT_VERSION ?= v1.59.0
GOLANGCILINT_VERSION ?= v1.59.1
GOFUMPT_VERSION ?= v0.6.0
GO_VERSION ?= 1.22.3
GO_VERSION ?= 1.22.4
GO_BUILDFLAGS ?=
GO_LDFLAGS ?=
CGO_ENABLED ?= 0
Expand Down
16 changes: 14 additions & 2 deletions blkid/internal/cstruct/cstruct.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,33 @@ func main() {
comment = name
}

g.Printf("// Get_%s returns %s.\n", name, comment)

switch typ {
case "uint64_t":
g.Printf("// Get_%s returns %s.\n", name, comment)
g.Printf("func (s %s) Get_%s() uint64 {\nreturn binary.%s.Uint64(s[%d:%d])\n}\n", structName, name, endianness, size, size+8)
g.Printf("// Put_%s sets %s.\n", name, comment)
g.Printf("func (s %s) Put_%s(v uint64) {\nbinary.%s.PutUint64(s[%d:%d], v)\n}\n", structName, name, endianness, size, size+8)

size += 8
case "uint32_t":
g.Printf("// Get_%s returns %s.\n", name, comment)
g.Printf("func (s %s) Get_%s() uint32 {\nreturn binary.%s.Uint32(s[%d:%d])\n}\n", structName, name, endianness, size, size+4)
g.Printf("// Put_%s sets %s.\n", name, comment)
g.Printf("func (s %s) Put_%s(v uint32) {\nbinary.%s.PutUint32(s[%d:%d], v)\n}\n", structName, name, endianness, size, size+4)

size += 4
case "uint16_t":
g.Printf("// Get_%s returns %s.\n", name, comment)
g.Printf("func (s %s) Get_%s() uint16 {\nreturn binary.%s.Uint16(s[%d:%d])\n}\n", structName, name, endianness, size, size+2)
g.Printf("// Put_%s sets %s.\n", name, comment)
g.Printf("func (s %s) Put_%s(v uint16) {\nbinary.%s.PutUint16(s[%d:%d], v)\n}\n", structName, name, endianness, size, size+2)

size += 2
case "uint8_t", "unsigned char":
g.Printf("// Get_%s returns %s.\n", name, comment)
g.Printf("func (s %s) Get_%s() byte {\nreturn s[%d]\n}\n", structName, name, size)
g.Printf("// Put_%s sets %s.\n", name, comment)
g.Printf("func (s %s) Put_%s(v byte) {\ns[%d] = v\n}\n", structName, name, size)

size++
}
Expand All @@ -121,6 +131,8 @@ func main() {

g.Printf("// Get_%s returns %s.\n", name, comment)
g.Printf("func (s %s) Get_%s() []byte {\nreturn s[%d:%d]\n}\n", structName, name, size, size+fieldSize)
g.Printf("// Put_%s sets %s.\n", name, comment)
g.Printf("func (s %s) Put_%s(v []byte) {\ncopy(s[%d:%d], v)\n}\n", structName, name, size, size+fieldSize)

size += fieldSize
case uintSliceRe.MatchString(line):
Expand Down
Loading
Loading