Skip to content

Commit

Permalink
chore(alpm): linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Jul 3, 2021
1 parent 1e98d80 commit 022c351
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
4 changes: 1 addition & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ linters:
- goconst
- gofmt
- goimports
- golint
- revive
- gosec
- gosimple
- govet
Expand Down Expand Up @@ -41,8 +41,6 @@ linters:
linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0
gocyclo:
min-complexity: 15
dupl:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WORKDIR /app

RUN pacman -Syu --overwrite=* --needed --noconfirm go

RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.39.0
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.41.1

COPY go.mod .

Expand Down
28 changes: 14 additions & 14 deletions callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,37 @@ func DefaultLogCallback(ctx interface{}, lvl LogLevel, s string) {
}

//export go_alpm_go_log_callback
func go_alpm_go_log_callback(go_cb unsafe.Pointer, go_ctx C.go_ctx_t, lvl C.alpm_loglevel_t, s *C.char) {
cb := *(*logCallbackSig)(go_cb)
ctx := logCallbackContextPool[go_ctx]
func go_alpm_go_log_callback(goCb unsafe.Pointer, goCtx C.go_ctx_t, lvl C.alpm_loglevel_t, s *C.char) {
cb := *(*logCallbackSig)(goCb)
ctx := logCallbackContextPool[goCtx]

cb(ctx, LogLevel(lvl), C.GoString(s))
}

//export go_alpm_go_question_callback
func go_alpm_go_question_callback(go_cb unsafe.Pointer, go_ctx C.go_ctx_t, question *C.alpm_question_t) {
func go_alpm_go_question_callback(goCb unsafe.Pointer, goCtx C.go_ctx_t, question *C.alpm_question_t) {
q := (*C.alpm_question_any_t)(unsafe.Pointer(question))

cb := *(*questionCallbackSig)(go_cb)
ctx := questionCallbackContextPool[go_ctx]
cb := *(*questionCallbackSig)(goCb)
ctx := questionCallbackContextPool[goCtx]

cb(ctx, QuestionAny{q})
}

func (h *Handle) SetLogCallback(cb logCallbackSig, ctx interface{}) {
go_cb := unsafe.Pointer(&cb)
go_ctx := C.go_ctx_t(h.ptr)
goCb := unsafe.Pointer(&cb)
goCtx := C.go_ctx_t(h.ptr)

logCallbackContextPool[go_ctx] = ctx
logCallbackContextPool[goCtx] = ctx

C.go_alpm_set_log_callback(h.ptr, go_cb, go_ctx)
C.go_alpm_set_log_callback(h.ptr, goCb, goCtx)
}

func (h *Handle) SetQuestionCallback(cb questionCallbackSig, ctx interface{}) {
go_cb := unsafe.Pointer(&cb)
go_ctx := C.go_ctx_t(h.ptr)
goCb := unsafe.Pointer(&cb)
goCtx := C.go_ctx_t(h.ptr)

questionCallbackContextPool[go_ctx] = ctx
questionCallbackContextPool[goCtx] = ctx

C.go_alpm_set_question_callback(h.ptr, go_cb, go_ctx)
C.go_alpm_set_question_callback(h.ptr, goCb, goCtx)
}
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (db *DB) Search(targets []string) IPackageList {
needles = C.alpm_list_add(needles, unsafe.Pointer(C.CString(str)))
}

ok := C.alpm_db_search(db.ptr, needles, &ret)
ok := C.alpm_db_search(db.ptr, needles, &ret) //nolint
if ok != 0 {
return PackageList{nil, db.handle}
}
Expand Down
2 changes: 0 additions & 2 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import "C"
// The Error type represents error codes from libalpm.
type Error C.alpm_errno_t

var _ error = Error(0)

// The string representation of an error is given by C function
// alpm_strerror().
func (er Error) Error() string {
Expand Down
2 changes: 1 addition & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func convertFilelist(files *C.alpm_filelist_t) []File {
Data: uintptr(unsafe.Pointer(files.files)),
}

cFiles := *(*[]C.alpm_file_t)(unsafe.Pointer(&rawItems)) // nolint
cFiles := *(*[]C.alpm_file_t)(unsafe.Pointer(&rawItems)) //nolint

for i := 0; i < size; i++ {
if file, err := convertFile(&cFiles[i]); err == nil {
Expand Down

0 comments on commit 022c351

Please sign in to comment.