Skip to content
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

MYNEWT-583; newt - allow use of specific tag/repository revision. #55

Closed
wants to merge 2 commits into from

Conversation

mkiiskila
Copy link
Contributor

No description provided.

"then modify your project.yml so that it does.\n")
for {
for i, vers := range versions {
fmt.Printf(" %d) %s\n", i, vers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should "vers" be converted to a string here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it calls the String() method for it automagically, presumably due to %s on the format string.
However, I can add the explicit call to make it more clear what's going on.

@mkiiskila
Copy link
Contributor Author

Updated pull request.

@ccollins476ad
Copy link
Contributor

Thanks, Marko. I don't think String() gets called automatically. At least, it didn't when I tried it in the Go playground. I did that test a while ago and no longer have the exact code I tested, though.

@ccollins476ad
Copy link
Contributor

Just an FYI- here is a playground program which I think reproduces this case: https://play.golang.org/p/UP8i8vo1oZ

package main

import (
	"fmt"
)

type S struct {
	a int
}

func (s *S) String() string {
	return fmt.Sprintf("%d", s.a)
}

func main() {
	s := S{5}
	fmt.Printf("s=%s\n", s)
}

Output:

s={%!s(int=5)}

Program exited.

Maybe there is something different in this example?

@ccollins476ad
Copy link
Contributor

Btw, I figured out why my playground example wasn't working. The String() function operated on a *S, but I was passing a plain S to Printf. I updated the example code and now it does work (https://play.golang.org/p/4kMNJ8NdEB):

package main

import (
	"fmt"
)

type S struct {
	a int
}

func (s *S) String() string {
	return fmt.Sprintf("%d", s.a)
}

func main() {
	s := &S{5}
	fmt.Printf("s=%s\n", s)
}
s=5

Program exited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants