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
+16.9k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+9k Golang : Go as a script or running go with shebang/hashbang style
+3.6k Java : Get FX sentiment from website example
+10.7k Golang : Underscore string example
+6.9k Default cipher that OpenSSL used to encrypt a PEM file
+18.8k Golang : Implement getters and setters
+6.4k PHP : Proper way to get UTF-8 character or string length
+30.9k error: trying to remove "yum", which is protected
+23.5k Golang : Get ASCII code from a key press(cross-platform) example
+18.6k Golang : Get download file size
+23.9k Golang : Fix type interface{} has no field or no methods and type assertions example
+14.3k Golang : How to shuffle elements in array or slice?