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
+8.1k Golang : Append and add item in slice
+35.5k Golang : Smarter Error Handling with strings.Contains()
+7.1k Golang : Validate credit card example
+5.9k Golang : Denco multiplexer example
+6.1k Golang : Missing Subversion command
+41.9k Golang : How do I convert int to uint8?
+7.7k Golang : Test if an input is an Armstrong number example
+11.6k Golang : Surveillance with web camera and OpenCV
+26k Golang : Convert IP address string to long ( unsigned 32-bit integer )
+13k Golang : Get terminal width and height example
+14k Golang : Fix cannot use buffer (type bytes.Buffer) as type io.Writer(Write method has pointer receiver) error
+7.1k Golang : Transform lisp or spinal case to Pascal case example