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
+5.9k Facebook : How to force facebook to scrape latest URL link data?
+30.8k Golang : Download file example
+36.4k Golang : Convert date or time stamp from string to time.Time type
+17.1k Golang : Capture stdout of a child process and act according to the result
+7.3k Golang : How to fix html/template : "somefile" is undefined error?
+4.3k Javascript : How to show different content with noscript?
+13.4k Golang : Generate Code128 barcode
+5.6k Swift : Get substring with rangeOfString() function example
+9.4k Golang : Qt Yes No and Quit message box example
+19.7k Golang : Archive directory with tar and gzip
+5.7k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+4.4k Golang : Valued expressions and functions example