hexdigest / gowrap

GoWrap is a command line tool for generating decorators for Go interfaces
MIT License
1.06k stars 82 forks source link

Can't loading template during the gen #85

Open tuxoo opened 6 months ago

tuxoo commented 6 months ago

good afternoon

I've tried to generate a tracing wrapper by my custom teplate which is uploading from github https://github.com/XeniaBgd/templates/blob/main/tracing

The command is : gowrap gen -p ./internal/domain/repository -i Repository -t https://raw.githubusercontent.com/XeniaBgd/templates/main/tracing -o ./internal/providers/analytics/tracing.go

But I've got this error: "failed to load template: open https://raw.githubusercontent.com/XeniaBgd/templates/main/tracing: The filename, directory name, or volume label syntax is incorrect"

I've checked code https://github.com/hexdigest/gowrap/blob/master/cmd_generate.go#L191

func underlyingErrorIs(err, target error) bool { // Note that this function is not errors.Is: // underlyingError only unwraps the specific error-wrapping types // that it historically did, not all errors implementing Unwrap(). err = underlyingError(err) if err == target { return true } // To preserve prior behavior, only examine syscall errors. e, ok := err.(syscallErrorType) return ok && e.Is(target) }

My error was "internal/syscall/windows.ERROR_INVALID_NAME (123)". That's why the function above returned false.

//if !os.IsNotExist(err) { // return //}

Without this code everything is ok.

Could somebody explain me why was that?

jeroenrinzema commented 6 days ago

Hi @tuxoo, I am facing the same issue. It seems to be the issue that gowrap is fetching it's templates directly from Github. You could hit the limits by running gowrap too many times.

@hexdigest would it be an idea to embed the templates within gowrap? This would resole the issue reported by @tuxoo, allow gowrap to be executed without any internet connection, and improve the security of gowrap by avoiding to fetch code templates from an external source.