Code maintenance: Unix abstraction interface

- Used for creating the tun device if it does not exist
- Mocks generated for testing
This commit is contained in:
Quentin McGaw
2020-12-29 01:02:47 +00:00
parent 8dd38fd182
commit 7058373916
7 changed files with 108 additions and 11 deletions

24
internal/unix/unix.go Normal file
View File

@@ -0,0 +1,24 @@
package unix
import sysunix "golang.org/x/sys/unix"
//go:generate mockgen -destination=mock_$GOPACKAGE/$GOFILE . Unix
type Unix interface {
Mkdev(major uint32, minor uint32) uint64
Mknod(path string, mode uint32, dev int) (err error)
}
func New() Unix {
return &unix{}
}
type unix struct{}
func (u *unix) Mkdev(major uint32, minor uint32) uint64 {
return sysunix.Mkdev(major, minor)
}
func (u *unix) Mknod(path string, mode uint32, dev int) (err error) {
return sysunix.Mknod(path, mode, dev)
}