获取 syslog.Writer 未定义

huangapple go评论76阅读模式
英文:

Getting syslog.Writer undefined

问题

我已经创建了以下类似的自定义类型。

import (
    "encoding/json"
    "log"
    "log/syslog"
    "strconv"
    "time"
)

type MyLogger struct {
    w       *syslog.Writer
    LogName string
}

我遇到了syslog.Writer未定义的错误。即使我在Go Playground中尝试了相同的代码,也会出现相同的错误。

这是在Go Playground上的链接

英文:

I have created the custom type with like following.

import (
    "encoding/json"
     "log"
     "log/syslog"
     "strconv"
     "time"
)

type MyLogger struct {
     w       *syslog.Writer
     LogName string
}

And I'm getting error syslog.writer undefined. Even I tried the same in golang play ground and its giving same error.

https://play.golang.org/p/2unuwHBoBE

答案1

得分: 6

根据https://blog.golang.org/playground,

为了将用户程序与Google的基础设施隔离开来,后端在Native Client(或“NaCl”)下运行它们。

而根据https://golang.org/pkg/log/syslog/,

此包在Windows上未实现。由于syslog包已经冻结,鼓励Windows用户使用标准库之外的包。有关背景,请参阅https://golang.org/issue/1108。

此包在Plan 9上未实现。

此包在NaCl(Native Client)上未实现。

你正在使用Windows,而Go Playground正在使用NaCl,这两者都没有实现syslog。

英文:

According to https://blog.golang.org/playground,

> To isolate user programs from Google's infrastructure, the back end runs them under Native Client (or "NaCl")

And from the https://golang.org/pkg/log/syslog/

> This package is not implemented on Windows. As the syslog package is frozen, Windows users are encouraged to use a package outside of the standard library. For background, see https://golang.org/issue/1108.
>
> This package is not implemented on Plan 9.
>
> This package is not implemented on NaCl (Native Client).

You are using Windows, and Go Playground is using NaCl, which both syslog is not implemented.

huangapple
  • 本文由 发表于 2017年2月7日 14:21:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/42083059.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定