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条)

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路