先看看代码:
g_log, err := syslog.NewLogger(syslog.LOG_INFO, )
再看看syslog的源码:
// NewLogger creates a log.Logger whose output is written to the
// system log service with the specified priority, a combination of
// the syslog facility and severity. The logFlag argument is the flag
// set passed through to log.New to create the Logger.
func NewLogger(p Priority, logFlag int) (*log.Logger, error) {
s, err := New(p, "")
if err != nil {
return nil, err
}
return log.New(s, "", logFlag), nil
}
按理说这么使用是没错的,但是在Windows环境下编译的时候就会抛出:
.\demo80.go::: undefined: syslog.NewLogger
.\demo80.go::: undefined: syslog.LOG_INFO
这就不对了,明明是有的,但是却抛出未定义的错误。
那我们试试在Linux环境下编译会怎样:
root@iZwz9hojvn6vym3t4ua045Z:/home/TimLiu/go/src/GolangTraining/SyslogTraining# go build
root@iZwz9hojvn6vym3t4ua045Z:/home/TimLiu/go/src/GolangTraining/SyslogTraining#
没有错误抛出,那就说明这个syslog包的问题