How to print some variable output inside golang source code?

While debugging an issue I require to see what are the values of different variables for that I need to print variables?

But the while importing “fmt” package it throws an error " go/src/time/format.go:9: can’t find import: “fmt” "

Can somebody point out where I am missing something ?

Can you post your code?

The following code snippet is from go/src/format.go file , line number 809 to 813

	case stdHour:
		hour, value, err = getnum(value, false)
                   fmt.Println(hour,value)     // this line is leading to error
		if hour < 0 || 24 <= hour {
			rangeErrString = "hour"
		}

That’s the time package of the standard library, not your code. Are you attempting to drop in fmt.Println statements within the standard library? What are you trying to debug in particular? (i.e. what’s the motivation - not the solution you’ve settled on)

yes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.