Golang fmt.Println() function examples
package fmt
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
Golang fmt.Println() function usage examples
Example 1 :
...
if err != nil {
fmt.Println("Error queue binding", err, "queue", queueName, "bindingKey", bindingKey)
}
...
Example 2:
func ToJson(query *Query) (string, error) {
var errString string = ""
if query.Error != nil {
errString = query.Error.Error()
}
d := outputMessage{
Id: query.Id,
Command: convertCommandToCommandString(query.Cmd),
Community: query.Community,
Oids: query.Oids,
Timeout: query.Timeout,
Retries: query.Retries,
Destination: query.Destination,
Response: query.Response,
Error: errString,
}
fmt.Println(d)
b, err := json.Marshal(d)
if err != nil {
return "", err
}
return string(b), nil
}
Reference :
Advertisement
Something interesting
Tutorials
+11.6k SSL : The certificate is not trusted because no issuer chain was provided
+5.8k Golang : Launching your executable inside a console under Linux
+31.7k Golang : How to convert(cast) string to IP address?
+8.5k Golang : How to check if input string is a word?
+8.8k Golang : Random integer with rand.Seed() within a given range
+10.9k Golang : Sieve of Eratosthenes algorithm
+10.8k Android Studio : Checkbox for user to select options example
+5.8k Cash Flow : 50 days to pay your credit card debt
+11.7k Golang : Find age or leap age from date of birth example
+6.3k Golang : Selection sort example
+12.5k Golang : HTTP response JSON encoded data
+17k Golang : How to save log messages to file?