diff --git a/backuptar/tar.go b/backuptar/tar.go index cb461ca3..6149a196 100644 --- a/backuptar/tar.go +++ b/backuptar/tar.go @@ -15,7 +15,7 @@ import ( "syscall" "time" - "github.com/Microsoft/go-winio" + "github.com/microsoft/go-winio" "golang.org/x/sys/windows" ) diff --git a/backuptar/tar_test.go b/backuptar/tar_test.go index 8be0bf34..77b8ea4b 100644 --- a/backuptar/tar_test.go +++ b/backuptar/tar_test.go @@ -11,7 +11,7 @@ import ( "reflect" "testing" - "github.com/Microsoft/go-winio" + "github.com/microsoft/go-winio" ) func ensurePresent(t *testing.T, m map[string]string, keys ...string) { diff --git a/go.mod b/go.mod index 98a8dea0..bea7abd9 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,8 @@ -module github.com/Microsoft/go-winio +module github.com/microsoft/go-winio -go 1.12 +go 1.16 require ( - github.com/pkg/errors v0.9.1 - github.com/sirupsen/logrus v1.7.0 - golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c + github.com/sirupsen/logrus v1.8.1 + golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea ) diff --git a/go.sum b/go.sum index aa6ad3b5..7aceb813 100644 --- a/go.sum +++ b/go.sum @@ -1,14 +1,11 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea h1:+WiDlPBBaO+h9vPNZi8uJ3k4BkKQB7Iow3aqwHVA5hI= +golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/hvsock.go b/hvsock.go index b632f8f8..b86b2237 100644 --- a/hvsock.go +++ b/hvsock.go @@ -11,7 +11,7 @@ import ( "time" "unsafe" - "github.com/Microsoft/go-winio/pkg/guid" + "github.com/microsoft/go-winio/pkg/guid" ) //sys bind(s syscall.Handle, name unsafe.Pointer, namelen int32) (err error) [failretval==socketError] = ws2_32.bind diff --git a/pkg/etw/eventopt.go b/pkg/etw/eventopt.go index eaace688..b7ed8d8b 100644 --- a/pkg/etw/eventopt.go +++ b/pkg/etw/eventopt.go @@ -3,7 +3,7 @@ package etw import ( - "github.com/Microsoft/go-winio/pkg/guid" + "github.com/microsoft/go-winio/pkg/guid" ) type eventOptions struct { diff --git a/pkg/etw/newprovider.go b/pkg/etw/newprovider.go index 581ef595..30e08696 100644 --- a/pkg/etw/newprovider.go +++ b/pkg/etw/newprovider.go @@ -8,7 +8,7 @@ import ( "encoding/binary" "unsafe" - "github.com/Microsoft/go-winio/pkg/guid" + "github.com/microsoft/go-winio/pkg/guid" "golang.org/x/sys/windows" ) @@ -65,7 +65,6 @@ func NewProviderWithOptions(name string, options ...ProviderOpt) (provider *Prov eventInfoClassProviderSetTraits, uintptr(unsafe.Pointer(&provider.metadata[0])), uint32(len(provider.metadata))); err != nil { - return nil, err } diff --git a/pkg/etw/provider.go b/pkg/etw/provider.go index e912b51b..48b6b4e2 100644 --- a/pkg/etw/provider.go +++ b/pkg/etw/provider.go @@ -8,7 +8,7 @@ import ( "strings" "unicode/utf16" - "github.com/Microsoft/go-winio/pkg/guid" + "github.com/microsoft/go-winio/pkg/guid" "golang.org/x/sys/windows" ) diff --git a/pkg/etw/provider_test.go b/pkg/etw/provider_test.go index 6b7c5ef8..8fbfeba4 100644 --- a/pkg/etw/provider_test.go +++ b/pkg/etw/provider_test.go @@ -5,7 +5,7 @@ package etw import ( "testing" - "github.com/Microsoft/go-winio/pkg/guid" + "github.com/microsoft/go-winio/pkg/guid" ) func mustGUIDFromString(t *testing.T, s string) guid.GUID { diff --git a/pkg/etw/sample/sample.go b/pkg/etw/sample/sample.go index 0424fb86..255be5cd 100644 --- a/pkg/etw/sample/sample.go +++ b/pkg/etw/sample/sample.go @@ -8,8 +8,8 @@ import ( "fmt" "os" - "github.com/Microsoft/go-winio/pkg/etw" - "github.com/Microsoft/go-winio/pkg/guid" + "github.com/microsoft/go-winio/pkg/etw" + "github.com/microsoft/go-winio/pkg/guid" "github.com/sirupsen/logrus" ) @@ -25,7 +25,6 @@ func main() { } provider, err := etw.NewProvider("TestProvider", callback) - if err != nil { logrus.Error(err) return @@ -37,7 +36,6 @@ func main() { }() providerWithGroup, err := etw.NewProviderWithOptions("TestProviderWithGroup", etw.WithGroup(group), etw.WithCallback(callback)) - if err != nil { logrus.Error(err) return diff --git a/pkg/etwlogrus/hook.go b/pkg/etwlogrus/hook.go index 4332af56..a3de6dc1 100644 --- a/pkg/etwlogrus/hook.go +++ b/pkg/etwlogrus/hook.go @@ -5,7 +5,7 @@ package etwlogrus import ( "sort" - "github.com/Microsoft/go-winio/pkg/etw" + "github.com/microsoft/go-winio/pkg/etw" "github.com/sirupsen/logrus" ) diff --git a/pkg/security/grantvmgroupaccess.go b/pkg/security/grantvmgroupaccess.go index fca24159..60292078 100644 --- a/pkg/security/grantvmgroupaccess.go +++ b/pkg/security/grantvmgroupaccess.go @@ -3,11 +3,10 @@ package security import ( + "fmt" "os" "syscall" "unsafe" - - "github.com/pkg/errors" ) type ( @@ -72,7 +71,7 @@ func GrantVmGroupAccess(name string) error { // Stat (to determine if `name` is a directory). s, err := os.Stat(name) if err != nil { - return errors.Wrapf(err, "%s os.Stat %s", gvmga, name) + return fmt.Errorf("%s os.Stat %s: %w", gvmga, name, err) } // Get a handle to the file/directory. Must defer Close on success. @@ -88,7 +87,7 @@ func GrantVmGroupAccess(name string) error { sd := uintptr(0) origDACL := uintptr(0) if err := getSecurityInfo(fd, uint32(ot), uint32(si), nil, nil, &origDACL, nil, &sd); err != nil { - return errors.Wrapf(err, "%s GetSecurityInfo %s", gvmga, name) + return fmt.Errorf("%s GetSecurityInfo %s: %w", gvmga, name, err) } defer syscall.LocalFree((syscall.Handle)(unsafe.Pointer(sd))) @@ -102,7 +101,7 @@ func GrantVmGroupAccess(name string) error { // And finally use SetSecurityInfo to apply the updated DACL. if err := setSecurityInfo(fd, uint32(ot), uint32(si), uintptr(0), uintptr(0), newDACL, uintptr(0)); err != nil { - return errors.Wrapf(err, "%s SetSecurityInfo %s", gvmga, name) + return fmt.Errorf("%s SetSecurityInfo %s: %w", gvmga, name, err) } return nil @@ -120,7 +119,7 @@ func createFile(name string, isDir bool) (syscall.Handle, error) { } fd, err := syscall.CreateFile(&namep[0], da, sm, nil, syscall.OPEN_EXISTING, fa, 0) if err != nil { - return 0, errors.Wrapf(err, "%s syscall.CreateFile %s", gvmga, name) + return 0, fmt.Errorf("%s syscall.CreateFile %s: %w", gvmga, name, err) } return fd, nil } @@ -131,7 +130,7 @@ func generateDACLWithAcesAdded(name string, isDir bool, origDACL uintptr) (uintp // Generate pointers to the SIDs based on the string SIDs sid, err := syscall.StringToSid(sidVmGroup) if err != nil { - return 0, errors.Wrapf(err, "%s syscall.StringToSid %s %s", gvmga, name, sidVmGroup) + return 0, fmt.Errorf("%s syscall.StringToSid %s %s: %w", gvmga, name, sidVmGroup, err) } inheritance := inheritModeNoInheritance @@ -154,7 +153,7 @@ func generateDACLWithAcesAdded(name string, isDir bool, origDACL uintptr) (uintp modifiedDACL := uintptr(0) if err := setEntriesInAcl(uintptr(uint32(1)), uintptr(unsafe.Pointer(&eaArray[0])), origDACL, &modifiedDACL); err != nil { - return 0, errors.Wrapf(err, "%s SetEntriesInAcl %s", gvmga, name) + return 0, fmt.Errorf("%s SetEntriesInAcl %s: %w", gvmga, name, err) } return modifiedDACL, nil diff --git a/tools/etw-provider-gen/main.go b/tools/etw-provider-gen/main.go index 9e6df9d6..61f99f53 100644 --- a/tools/etw-provider-gen/main.go +++ b/tools/etw-provider-gen/main.go @@ -7,11 +7,11 @@ import ( "fmt" "os" - "github.com/Microsoft/go-winio/pkg/etw" + "github.com/microsoft/go-winio/pkg/etw" ) func main() { - var pn = flag.String("provider-name", "", "The human readable ETW provider name to be converted into GUID format") + pn := flag.String("provider-name", "", "The human readable ETW provider name to be converted into GUID format") flag.Parse() if pn == nil || *pn == "" { fmt.Fprint(os.Stderr, "--provider-name is required") diff --git a/vhd/vhd.go b/vhd/vhd.go index a33a36c0..a4742515 100644 --- a/vhd/vhd.go +++ b/vhd/vhd.go @@ -6,8 +6,7 @@ import ( "fmt" "syscall" - "github.com/Microsoft/go-winio/pkg/guid" - "github.com/pkg/errors" + "github.com/microsoft/go-winio/pkg/guid" "golang.org/x/sys/windows" ) @@ -155,7 +154,7 @@ func CreateVhdx(path string, maxSizeInGb, blockSizeInMb uint32) error { // DetachVirtualDisk detaches a virtual hard disk by handle. func DetachVirtualDisk(handle syscall.Handle) (err error) { if err := detachVirtualDisk(handle, 0, 0); err != nil { - return errors.Wrap(err, "failed to detach virtual disk") + return fmt.Errorf("failed to detach virtual disk: %w", err) } return nil } @@ -185,7 +184,7 @@ func AttachVirtualDisk(handle syscall.Handle, attachVirtualDiskFlag AttachVirtua parameters, nil, ); err != nil { - return errors.Wrap(err, "failed to attach virtual disk") + return fmt.Errorf("failed to attach virtual disk: %w", err) } return nil } @@ -209,7 +208,7 @@ func AttachVhd(path string) (err error) { AttachVirtualDiskFlagNone, ¶ms, ); err != nil { - return errors.Wrap(err, "failed to attach virtual disk") + return fmt.Errorf("failed to attach virtual disk: %w", err) } return nil } @@ -246,7 +245,7 @@ func OpenVirtualDiskWithParameters(vhdPath string, virtualDiskAccessMask Virtual parameters, &handle, ); err != nil { - return 0, errors.Wrap(err, "failed to open virtual disk") + return 0, fmt.Errorf("failed to open virtual disk: %w", err) } return handle, nil } @@ -272,7 +271,7 @@ func CreateVirtualDisk(path string, virtualDiskAccessMask VirtualDiskAccessMask, nil, &handle, ); err != nil { - return handle, errors.Wrap(err, "failed to create virtual disk") + return handle, fmt.Errorf("failed to create virtual disk: %w", err) } return handle, nil } @@ -290,7 +289,7 @@ func GetVirtualDiskPhysicalPath(handle syscall.Handle) (_ string, err error) { &diskPathSizeInBytes, &diskPhysicalPathBuf[0], ); err != nil { - return "", errors.Wrap(err, "failed to get disk physical path") + return "", fmt.Errorf("failed to get disk physical path: %w", err) } return windows.UTF16ToString(diskPhysicalPathBuf[:]), nil } diff --git a/wim/decompress.go b/wim/decompress.go index 12d5196b..fd0d59d2 100644 --- a/wim/decompress.go +++ b/wim/decompress.go @@ -7,7 +7,7 @@ import ( "io" "io/ioutil" - "github.com/Microsoft/go-winio/wim/lzx" + "github.com/microsoft/go-winio/wim/lzx" ) const chunkSize = 32768 // Compressed resource chunk size diff --git a/wim/validate/validate.go b/wim/validate/validate.go index 2536c002..82d9fc1c 100644 --- a/wim/validate/validate.go +++ b/wim/validate/validate.go @@ -7,7 +7,7 @@ import ( "fmt" "os" - "github.com/Microsoft/go-winio/wim" + "github.com/microsoft/go-winio/wim" ) func main() {