2

In the following example, end of URL / is removed, is there a way to keep the /?

package main import ( "fmt" "net/url" "path" ) func main() { u, _ := url.Parse("http://localhost:5100") relative, _ := url.Parse(path.Join("hello/")) fmt.Println(u.ResolveReference(relative)) } 

Output:

http://localhost:5100/hello 

1 Answer 1

2

I figured out the answer, which is not to use path.Join:

package main import ( "fmt" "net/url" ) func main() { u, _ := url.Parse("http://localhost:5100") relative, _ := url.Parse("hello/") fmt.Println(u.ResolveReference(relative)) } 

Output:

http://localhost:5100/hello/ 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.