Is it possible to run Go code as a script?

后端 未结 5 2045
梦如初夏
梦如初夏 2021-02-05 17:21

As Go is becoming the language of the \"system\". I wonder if it\'s possible to run Go code as a script, without compiling it, is there any possibility to do that?

The

5条回答
  •  一向
    一向 (楼主)
    2021-02-05 17:53

    see Neugram, Go scripting . From it's documentation:

    #!/usr/bin/ng
    
    // Start a web server to serve files.
    import "net/http"
    pwd := $$ echo $PWD $$
    h := http.FileServer(http.Dir(pwd))
    http.ListenAndServe(":8080", h)
    

提交回复
热议问题