diff --git a/common/windnsapi/syscall_stub.go b/common/windnsapi/dnsapi_stub.go similarity index 100% rename from common/windnsapi/syscall_stub.go rename to common/windnsapi/dnsapi_stub.go diff --git a/common/windnsapi/dnsapi_test.go b/common/windnsapi/dnsapi_test.go new file mode 100644 index 0000000..adf582d --- /dev/null +++ b/common/windnsapi/dnsapi_test.go @@ -0,0 +1,16 @@ +package windnsapi + +import ( + "runtime" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestDNSAPI(t *testing.T) { + if runtime.GOOS != "windows" { + t.SkipNow() + } + t.Parallel() + require.NoError(t, FlushResolverCache()) +} diff --git a/common/windnsapi/syscall_windows.go b/common/windnsapi/syscall_windows.go index 996253e..b41e525 100644 --- a/common/windnsapi/syscall_windows.go +++ b/common/windnsapi/syscall_windows.go @@ -3,4 +3,4 @@ package windnsapi //go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go syscall_windows.go // dnsapi.DnsFlushResolverCache is an undocumented function -//sys FlushResolverCache() (ret error) = dnsapi.DnsFlushResolverCache +//sys FlushResolverCache() (err error) = dnsapi.DnsFlushResolverCache diff --git a/common/windnsapi/zsyscall_windows.go b/common/windnsapi/zsyscall_windows.go index 44840a0..033c01c 100644 --- a/common/windnsapi/zsyscall_windows.go +++ b/common/windnsapi/zsyscall_windows.go @@ -43,10 +43,10 @@ var ( procDnsFlushResolverCache = moddnsapi.NewProc("DnsFlushResolverCache") ) -func FlushResolverCache() (ret error) { - r0, _, _ := syscall.Syscall(procDnsFlushResolverCache.Addr(), 0, 0, 0, 0) - if r0 != 0 { - ret = syscall.Errno(r0) +func FlushResolverCache() (err error) { + r1, _, e1 := syscall.Syscall(procDnsFlushResolverCache.Addr(), 0, 0, 0, 0) + if r1 == 0 { + err = errnoErr(e1) } return }