Skip to content

Commit 4f65ee3

Browse files
committed
do not export private members in an interface
1 parent 33b1001 commit 4f65ee3

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

.devcontainer/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
FROM docker.io/jguer/yay-builder
33

44
# Install extra packages (pacman-contrib and fish)
5-
RUN sudo pacman -Syu --noconfirm pacman-contrib fish git-delta openssh bat go
5+
# Note: Using -Sy instead of -Syu to avoid full system upgrade which fails
6+
# due to read-only /etc/resolv.conf and /etc/hosts during Docker build
7+
RUN sudo pacman -Sy --noconfirm pacman-contrib fish git-delta openssh bat go
68

79
# Set passwordless sudo for the docker user
810
RUN echo "docker ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/docker

interfaces.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ type IPackage interface {
7777
SyncNewVersion(l IDBList) IPackage
7878

7979
Type() string
80-
81-
// Get the underlying alpm pkg type
82-
getPmpkg() *C.alpm_pkg_t
8380
}
8481

8582
// IPackageList exports the alpm.PackageList symbols.

package.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,6 @@ func (pkg *Package) Type() string {
298298
return "alpm"
299299
}
300300

301-
func (pkg *Package) getPmpkg() *C.alpm_pkg_t {
302-
return pkg.pmpkg
303-
}
304-
305301
// SortBySize returns a PackageList sorted by size.
306302
func (l PackageList) SortBySize() IPackageList {
307303
pkgList := (*C.struct__alpm_list_t)(unsafe.Pointer(l.list))

trans.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ package alpm
1212
import "C"
1313

1414
import (
15+
"fmt"
1516
"unsafe"
1617
)
1718

19+
// ErrInvalidPackageType is returned when an invalid package type is used.
20+
var ErrInvalidPackageType = fmt.Errorf("invalid Package type")
21+
1822
func (h *Handle) TransInit(flags TransFlag) error {
1923
ret := C.alpm_trans_init(h.ptr, C.int(flags))
2024
if ret != 0 {
@@ -82,7 +86,12 @@ func (h *Handle) TransGetFlags() (TransFlag, error) {
8286
}
8387

8488
func (h *Handle) AddPkg(pkg IPackage) error {
85-
ret := C.alpm_add_pkg(h.ptr, pkg.getPmpkg())
89+
aPkg, ok := pkg.(*Package)
90+
if !ok {
91+
return ErrInvalidPackageType
92+
}
93+
94+
ret := C.alpm_add_pkg(h.ptr, aPkg.pmpkg)
8695
if ret != 0 {
8796
return h.LastError()
8897
}
@@ -91,7 +100,11 @@ func (h *Handle) AddPkg(pkg IPackage) error {
91100
}
92101

93102
func (h *Handle) RemovePkg(pkg IPackage) error {
94-
ret := C.alpm_remove_pkg(h.ptr, pkg.getPmpkg())
103+
aPkg, ok := pkg.(*Package)
104+
if !ok {
105+
return ErrInvalidPackageType
106+
}
107+
ret := C.alpm_remove_pkg(h.ptr, aPkg.pmpkg)
95108
if ret != 0 {
96109
return h.LastError()
97110
}

0 commit comments

Comments
 (0)