I am newbie to golang and fluentd. I am trying to build logging application using fluentd's logger library from github.com/fluent/fluent-logger-golang/fluent .
On 192.168.0.106 fluentd service is running and listening on 24224
Below is the program for logging in golang.
package main
import (
"github.com/fluent/fluent-logger-golang/fluent"
"fmt"
)
type Student struct {
name string
id_no int
age int
}
func main() {
logger,err :=fluent.New(fluent.Config{FluentHost:"192.168.0.106", FluentPort:24224})
fmt.Println(logger.BufferLimit)
if err != nil{
fmt.Println("error creating fluentd instance")
return
}
defer logger.Close()
tag := "fluentd-log-demo"
data := Student{"John",1234,25}
error := logger.Post(tag,data)
if error != nil{
panic(error)
}
}
I am getting lots of error after executing the binary file.
mahesh@ubuntu14:~/golang$ fluentd-log-demo
8388608
panic: reflect.Value.Interface: cannot return value obtained from unexported field or method
goroutine 1 [running]:
panic(0x5674e0, 0xc82000a6f0)
/home/mahesh/gotools/src/runtime/panic.go:464 +0x3e6
reflect.valueInterface(0x5674e0, 0xc820010300, 0xb8, 0x1, 0x0, 0x0)
/home/mahesh/gotools/src/reflect/value.go:919 +0xe7
reflect.Value.Interface(0x5674e0, 0xc820010300, 0xb8, 0x0, 0x0)
/home/mahesh/gotools/src/reflect/value.go:908 +0x48
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).PostWithTime(0xc82007a000, 0x603120, 0x10, 0xeceb11576, 0x28abb08c, 0x6d7bc0, 0x5b2060, 0xc820010300, 0x0, 0x0)
/home/mahesh/golib/src/github.com/fluent/fluent-logger-golang/fluent/fluent.go:139 +0x315
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).Post(0xc82007a000, 0x603120, 0x10, 0x5b2060, 0xc820010300, 0x0, 0x0)
/home/mahesh/golib/src/github.com/fluent/fluent-logger-golang/fluent/fluent.go:116 +0x96
main.main()
/home/mahesh/golang/src/GoBasics/fluentd-log-demo/main.go:25 +0x39e
mahesh@ubuntu14:~/golang$
Please help me in troubleshooting the issue.
Thank you