GoWSL icon indicating copy to clipboard operation
GoWSL copied to clipboard

Replace GPL log library import

Open jjradecki opened this issue 8 months ago • 0 comments

I was wondering if there's any explicit benefit from the github.com/0xrawsec/golang-utils library being imported? Looks to me like it's just being used for logging in one of the unit test files? Purely interested because it uses a GPL license which is preventing my from leveraging this library as a whole since I'd have to import that GPL licensed library into my project as well as a dependency which isn't permitted at my company.

I'd be happy to look at making this change to just use the std lib log library if that's acceptable, just wanted to get some understanding on the import and if I'm missing something. Thanks!

For ref, looks like these are the only functions that leverage that library right now through the 3 log.Warnf calls below:

 // cleanUpTestWslInstances finds all distros with a prefixed name and unregisters them.
 func cleanUpTestWslInstances(ctx context.Context) {
 	testInstances, err := testDistros(ctx)
 
 	if err != nil {
 		return
 	}
 	if len(testInstances) != 0 {
 		s := ""
 		for _, d := range testInstances {
 			s = s + "\n - " + d.Name()
 		}
 		log.Warnf("Cleanup: The following WSL distros were not properly cleaned up:%s", s)
 	}
 
 	for _, d := range testInstances {
 		err := uninstallDistro(d, true)
 		if err != nil {
 			log.Warnf("Cleanup: %v\n", err)
 		}
 	}
 }
 
 // backUpDefaultDistro returns a function to restore the default distro so the machine is restored to
 // its pre-testing state.
 func backUpDefaultDistro(ctx context.Context) (func(), error) {
 	distroName, ok, err := defaultDistro(ctx)
 	if err != nil {
 		return nil, fmt.Errorf("failed to back up default distro: %v", err)
 	}
 	if !ok {
 		return func() {}, nil // No distros registered: no backup needed
 	}
 	restore := func() {
 		if err := setDefaultDistro(ctx, distroName); err != nil {
 			log.Warnf("failed to restore default distro: %v", err)
 		}
 	}
 	return restore, nil
 }

jjradecki avatar Apr 16 '25 15:04 jjradecki