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
+40.5k Golang : Convert to io.ReadSeeker type
+16.8k Golang : Get own process identifier
+7.4k Golang : Scanf function weird error in Windows
+10.9k Golang : Get UDP client IP address and differentiate clients by port number
+19.5k Golang : Example for DSA(Digital Signature Algorithm) package functions
+8.8k Golang : Gorilla web tool kit schema example
+8.6k Golang : Progress bar with ∎ character
+9.1k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+8.2k Golang : HttpRouter multiplexer routing example
+5.4k Golang : Return multiple values from function
+8.6k Golang : Another camera capture GUI application with GTK and OpenCV
+14k Golang : Compress and decompress file with compress/flate example