dty3416 2013-09-27 04:52
浏览 60
已采纳

在OS X中自动启动godoc localhost服务器?

In Go, you can start HTTP server and then browse through the Go document via the specific port. For example, if you type in godoc -http=:3333 in Terminal, the localhost server starts working on port 3333 and you can then view the official Go document.

However, I would like to make it start automatically whenever I log in to the OS X system, since it is so powerful and convenient to write in Go code with even when I'm off the Wi-Fi connection. So is it feasible to use such daemon in OS X?

I have implemented and utilized the exact functionality in MongoDB from an example here, and it's exactly this kind of service that I want to achieve...

  • 写回答

3条回答 默认 最新

  • dsapkqaduj6718493 2013-09-27 11:50
    关注

    Put this in the folder ~/Library/LaunchAgents with a file name like org.golang.doc.example.plist:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN
               http://www.apple.com/DTDs/PropertyList-1.0.dtd >
    <plist version="1.0">
      <dict>
        <key>Label</key>
        <string>org.golang.doc.example</string>
        <key>ProgramArguments</key>
        <array>
          <string>/usr/local/go/bin/godoc</string>
          <string>-http=:6060</string>
        </array>
        <key>KeepAlive</key>
        <true />
      </dict>
    </plist>
    

    You may have to create the folder yourself.

    The next time you log into your account, godoc should automatically start on port 6060.

    (I have not tested it very well though. Feedback welcome!)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!