-
-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support go.mod replace version pinning #27
Conversation
Thanks, but I don't think I can accept this as-is. I'm not even aware of any problems in xcaddy right now. What is the problem? You'll have to motivate the reason for this change. |
My apologies, I should have created a formal issue first... Expected BehaviorUsing a go.mod:
buildenv initialization:
Current Behaviorgo.mod:
buildenv initialization:
Note the space in the replacement directive between the new ModulePath and Version. xcaddy currently builds the Steps to Reproduce
|
What is your xcaddy command though? Like, how can I reproduce the problem? I use |
I am running simply |
This is what xcaddy is trying to run with my
If you run that manually, you will see the same error However,
... works, but there is nothing currently in xcaddy, that I can tell, which reformats the components of the |
I see. I usually use
And so there is no version string. What is the use case for replace with a version string, rather than simply using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elegant fix though, thanks for the test cases too!
builder.go
Outdated
if r == "" { | ||
return "" | ||
} | ||
return regexp.MustCompile(`\sv`).ReplaceAllString(string(r), "@v") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's any need for regular expressions, and we can't assume the version starts with v
(it could be a commit or branch name):
if r == "" { | |
return "" | |
} | |
return regexp.MustCompile(`\sv`).ReplaceAllString(string(r), "@v") | |
return strings.Replace(string(r), " ", "@", 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand, the "version" here will always start with a v
. See: https://golang.org/ref/mod#versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can try it, but go get
accepts commits and branches too.
Make this change anyway (with a v if you want) and I can merge this.
See: Quite an annoying problem... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for the fix! This works for you then?
Yes this works. Thank you! 😃 |
Okay, thanks again! (I just pushed a couple minor tweaks.) I appreciate the contribution! |
Fix for error caused by replace directives with version pinning: