FAQ
Hi,

I've only recently started looking at Go, and I have a very early question:

Is it possible to dynamically (at run-time) load and unload modules? And if
so, how efficient is that?

I came across this project:

http://code.google.com/p/gopages/

And I'm wondering if it would be possible to compile and dynamically
load/unload pages dynamically.

Eventually making it possible to write a web-server that serves "gopages"
dynamically, without advance compilation - kind of like how Apache/PHP
works, but this presumably would be significantly faster and more
memory-efficient, since you'd be caching binary machine-code rather than
bytecode evaluated by a VM at run-time.

Thanks!

- Rasmus Schultz

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Ian Lance Taylor at Feb 28, 2013 at 7:08 pm

    On Thu, Feb 28, 2013 at 9:28 AM, Rasmus Schultz wrote:
    Is it possible to dynamically (at run-time) load and unload modules? And if
    so, how efficient is that?
    Currently there is no support for that. It is likely to happen some
    time in the future, but I don't know when. Not for Go 1.1.

    Ian

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Kyle Lemons at Feb 28, 2013 at 7:18 pm
    My typical recommendation in absence of dynamic loading would be to define
    an RPC mechanism and to spawn subprocesses as your "plugins." Loopback
    connections are typically very fast, and when you don't have to do
    inner-loop round trips between the binaries this typically performs well.
      It also gives you failure isolation: a plugin crash won't cause the main
    binary to crash.

    On Thu, Feb 28, 2013 at 9:28 AM, Rasmus Schultz wrote:

    Hi,

    I've only recently started looking at Go, and I have a very early question:

    Is it possible to dynamically (at run-time) load and unload modules? And
    if so, how efficient is that?

    I came across this project:

    http://code.google.com/p/gopages/

    And I'm wondering if it would be possible to compile and dynamically
    load/unload pages dynamically.

    Eventually making it possible to write a web-server that serves "gopages"
    dynamically, without advance compilation - kind of like how Apache/PHP
    works, but this presumably would be significantly faster and more
    memory-efficient, since you'd be caching binary machine-code rather than
    bytecode evaluated by a VM at run-time.

    Thanks!

    - Rasmus Schultz

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Wkharold at Feb 28, 2013 at 7:34 pm
    I second this recommendation; futher, rather than defining/desiging yet
    another RPC mechanism I usually urge people to check out 9p and the nice
    go9p library which allows your plugin to be "mounted" and its capabilities
    exposed as a file system.
    On Thursday, February 28, 2013 1:17:48 PM UTC-6, Kyle Lemons wrote:

    My typical recommendation in absence of dynamic loading would be to define
    an RPC mechanism and to spawn subprocesses as your "plugins." Loopback
    connections are typically very fast, and when you don't have to do
    inner-loop round trips between the binaries this typically performs well.
    It also gives you failure isolation: a plugin crash won't cause the main
    binary to crash.


    On Thu, Feb 28, 2013 at 9:28 AM, Rasmus Schultz <ras...@mindplay.dk<javascript:>
    wrote:
    Hi,

    I've only recently started looking at Go, and I have a very early
    question:

    Is it possible to dynamically (at run-time) load and unload modules? And
    if so, how efficient is that?

    I came across this project:

    http://code.google.com/p/gopages/

    And I'm wondering if it would be possible to compile and dynamically
    load/unload pages dynamically.

    Eventually making it possible to write a web-server that serves "gopages"
    dynamically, without advance compilation - kind of like how Apache/PHP
    works, but this presumably would be significantly faster and more
    memory-efficient, since you'd be caching binary machine-code rather than
    bytecode evaluated by a VM at run-time.

    Thanks!

    - Rasmus Schultz

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Kyle Lemons at Feb 28, 2013 at 8:38 pm
    Well, there's also net/rpc ;-)

    On Thu, Feb 28, 2013 at 11:34 AM, wkharold wrote:

    I second this recommendation; futher, rather than defining/desiging yet
    another RPC mechanism I usually urge people to check out 9p and the nice
    go9p library which allows your plugin to be "mounted" and its capabilities
    exposed as a file system.

    On Thursday, February 28, 2013 1:17:48 PM UTC-6, Kyle Lemons wrote:

    My typical recommendation in absence of dynamic loading would be to
    define an RPC mechanism and to spawn subprocesses as your "plugins."
    Loopback connections are typically very fast, and when you don't have to
    do inner-loop round trips between the binaries this typically performs
    well. It also gives you failure isolation: a plugin crash won't cause the
    main binary to crash.

    On Thu, Feb 28, 2013 at 9:28 AM, Rasmus Schultz wrote:

    Hi,

    I've only recently started looking at Go, and I have a very early
    question:

    Is it possible to dynamically (at run-time) load and unload modules? And
    if so, how efficient is that?

    I came across this project:

    http://code.google.com/p/**gopages/ <http://code.google.com/p/gopages/>

    And I'm wondering if it would be possible to compile and dynamically
    load/unload pages dynamically.

    Eventually making it possible to write a web-server that serves
    "gopages" dynamically, without advance compilation - kind of like how
    Apache/PHP works, but this presumably would be significantly faster and
    more memory-efficient, since you'd be caching binary machine-code rather
    than bytecode evaluated by a VM at run-time.

    Thanks!

    - Rasmus Schultz

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@**googlegroups.com.

    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Wkharold at Feb 28, 2013 at 8:56 pm
    Indeed; I'm just a huge fan of "everything is a file", ergo 9p ... WkH
    On Thursday, February 28, 2013 2:37:44 PM UTC-6, Kyle Lemons wrote:

    Well, there's also net/rpc ;-)


    On Thu, Feb 28, 2013 at 11:34 AM, wkharold <wkha...@gmail.com<javascript:>
    wrote:
    I second this recommendation; futher, rather than defining/desiging yet
    another RPC mechanism I usually urge people to check out 9p and the nice
    go9p library which allows your plugin to be "mounted" and its capabilities
    exposed as a file system.

    On Thursday, February 28, 2013 1:17:48 PM UTC-6, Kyle Lemons wrote:

    My typical recommendation in absence of dynamic loading would be to
    define an RPC mechanism and to spawn subprocesses as your "plugins."
    Loopback connections are typically very fast, and when you don't have to
    do inner-loop round trips between the binaries this typically performs
    well. It also gives you failure isolation: a plugin crash won't cause the
    main binary to crash.

    On Thu, Feb 28, 2013 at 9:28 AM, Rasmus Schultz wrote:

    Hi,

    I've only recently started looking at Go, and I have a very early
    question:

    Is it possible to dynamically (at run-time) load and unload modules?
    And if so, how efficient is that?

    I came across this project:

    http://code.google.com/p/**gopages/ <http://code.google.com/p/gopages/>

    And I'm wondering if it would be possible to compile and dynamically
    load/unload pages dynamically.

    Eventually making it possible to write a web-server that serves
    "gopages" dynamically, without advance compilation - kind of like how
    Apache/PHP works, but this presumably would be significantly faster and
    more memory-efficient, since you'd be caching binary machine-code rather
    than bytecode evaluated by a VM at run-time.

    Thanks!

    - Rasmus Schultz

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@**googlegroups.com.

    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Nate at Mar 1, 2013 at 10:05 pm
    When I tried to build the ramfs example in go9p it said:

    # code.google.com/p/go9p/p/srv/examples/ramfs
    ./ramfs.go:243: undefined: srv.StartStatsServer

    Do you know why?
    On Thursday, February 28, 2013 1:56:10 PM UTC-7, wkharold wrote:

    Indeed; I'm just a huge fan of "everything is a file", ergo 9p ... WkH
    On Thursday, February 28, 2013 2:37:44 PM UTC-6, Kyle Lemons wrote:

    Well, there's also net/rpc ;-)

    On Thu, Feb 28, 2013 at 11:34 AM, wkharold wrote:

    I second this recommendation; futher, rather than defining/desiging yet
    another RPC mechanism I usually urge people to check out 9p and the nice
    go9p library which allows your plugin to be "mounted" and its capabilities
    exposed as a file system.

    On Thursday, February 28, 2013 1:17:48 PM UTC-6, Kyle Lemons wrote:

    My typical recommendation in absence of dynamic loading would be to
    define an RPC mechanism and to spawn subprocesses as your "plugins."
    Loopback connections are typically very fast, and when you don't have to
    do inner-loop round trips between the binaries this typically performs
    well. It also gives you failure isolation: a plugin crash won't cause the
    main binary to crash.

    On Thu, Feb 28, 2013 at 9:28 AM, Rasmus Schultz wrote:

    Hi,

    I've only recently started looking at Go, and I have a very early
    question:

    Is it possible to dynamically (at run-time) load and unload modules?
    And if so, how efficient is that?

    I came across this project:

    http://code.google.com/p/**gopages/<http://code.google.com/p/gopages/>

    And I'm wondering if it would be possible to compile and dynamically
    load/unload pages dynamically.

    Eventually making it possible to write a web-server that serves
    "gopages" dynamically, without advance compilation - kind of like how
    Apache/PHP works, but this presumably would be significantly faster and
    more memory-efficient, since you'd be caching binary machine-code rather
    than bytecode evaluated by a VM at run-time.

    Thanks!

    - Rasmus Schultz

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@**googlegroups.com.

    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Wkharold at Mar 1, 2013 at 11:27 pm
    The stats_http.go file, where StartStatsServer lives, has a +build
    httpstats directive at the top of the file. I haven't fully grok'd all of
    the build switch magic but I would guess that stats_http.go didn't get
    built when you compiled it.
    On Friday, March 1, 2013 4:05:51 PM UTC-6, Nate wrote:

    When I tried to build the ramfs example in go9p it said:

    # code.google.com/p/go9p/p/srv/examples/ramfs
    ./ramfs.go:243: undefined: srv.StartStatsServer

    Do you know why?
    On Thursday, February 28, 2013 1:56:10 PM UTC-7, wkharold wrote:

    Indeed; I'm just a huge fan of "everything is a file", ergo 9p ... WkH
    On Thursday, February 28, 2013 2:37:44 PM UTC-6, Kyle Lemons wrote:

    Well, there's also net/rpc ;-)

    On Thu, Feb 28, 2013 at 11:34 AM, wkharold wrote:

    I second this recommendation; futher, rather than defining/desiging yet
    another RPC mechanism I usually urge people to check out 9p and the nice
    go9p library which allows your plugin to be "mounted" and its capabilities
    exposed as a file system.

    On Thursday, February 28, 2013 1:17:48 PM UTC-6, Kyle Lemons wrote:

    My typical recommendation in absence of dynamic loading would be to
    define an RPC mechanism and to spawn subprocesses as your "plugins."
    Loopback connections are typically very fast, and when you don't have to
    do inner-loop round trips between the binaries this typically performs
    well. It also gives you failure isolation: a plugin crash won't cause the
    main binary to crash.

    On Thu, Feb 28, 2013 at 9:28 AM, Rasmus Schultz wrote:

    Hi,

    I've only recently started looking at Go, and I have a very early
    question:

    Is it possible to dynamically (at run-time) load and unload modules?
    And if so, how efficient is that?

    I came across this project:

    http://code.google.com/p/**gopages/<http://code.google.com/p/gopages/>

    And I'm wondering if it would be possible to compile and dynamically
    load/unload pages dynamically.

    Eventually making it possible to write a web-server that serves
    "gopages" dynamically, without advance compilation - kind of like how
    Apache/PHP works, but this presumably would be significantly faster and
    more memory-efficient, since you'd be caching binary machine-code rather
    than bytecode evaluated by a VM at run-time.

    Thanks!

    - Rasmus Schultz

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@**googlegroups.com.

    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rasmus Schultz at Dec 9, 2013 at 6:16 pm
    Is anyone familiar with the Revel framework and can briefly explain how it
    accomplishes "hot swapping" of Controllers and views?

    Did something change in Go since I opened this thread in February?
    On Thursday, February 28, 2013 12:28:10 PM UTC-5, Rasmus Schultz wrote:

    Hi,

    I've only recently started looking at Go, and I have a very early question:

    Is it possible to dynamically (at run-time) load and unload modules? And
    if so, how efficient is that?

    I came across this project:

    http://code.google.com/p/gopages/

    And I'm wondering if it would be possible to compile and dynamically
    load/unload pages dynamically.

    Eventually making it possible to write a web-server that serves "gopages"
    dynamically, without advance compilation - kind of like how Apache/PHP
    works, but this presumably would be significantly faster and more
    memory-efficient, since you'd be caching binary machine-code rather than
    bytecode evaluated by a VM at run-time.

    Thanks!

    - Rasmus Schultz
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • André Moraes at Dec 9, 2013 at 6:31 pm

    On Mon, Dec 9, 2013 at 4:16 PM, Rasmus Schultz wrote:
    Is anyone familiar with the Revel framework and can briefly explain how it
    accomplishes "hot swapping" of Controllers and views?
    Usually this is done by using a proxy server (net/http/httputil) or
    the process could pass the FD of the TCP Listener to the child process
    and stop receiving new connections.

    The child process would be running the up-to-date code.

    You could check goagain on godoc.org
    (http://godoc.org/github.com/rcrowley/goagain)


    --
    André Moraes
    http://amoraes.inf

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rasmus Schultz at Dec 10, 2013 at 4:44 pm
    Well that is certainly interesting - thank you :-)
    On Monday, December 9, 2013 1:31:12 PM UTC-5, André Moraes wrote:
    On Mon, Dec 9, 2013 at 4:16 PM, Rasmus Schultz wrote:
    Is anyone familiar with the Revel framework and can briefly explain how it
    accomplishes "hot swapping" of Controllers and views?
    Usually this is done by using a proxy server (net/http/httputil) or
    the process could pass the FD of the TCP Listener to the child process
    and stop receiving new connections.

    The child process would be running the up-to-date code.

    You could check goagain on godoc.org
    (http://godoc.org/github.com/rcrowley/goagain)


    --
    André Moraes
    http://amoraes.inf
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rasmus Schultz at Dec 16, 2014 at 7:36 am
    So now, a year later, is there anything in the works for Go that will
    permit dynamic loading/unloading of code/modules?

    I think I heard or read something about DLL/SO support being in the works?
    On Tuesday, December 10, 2013 5:44:40 PM UTC+1, Rasmus Schultz wrote:

    Well that is certainly interesting - thank you :-)
    On Monday, December 9, 2013 1:31:12 PM UTC-5, André Moraes wrote:

    On Mon, Dec 9, 2013 at 4:16 PM, Rasmus Schultz <ras...@mindplay.dk>
    wrote:
    Is anyone familiar with the Revel framework and can briefly explain how it
    accomplishes "hot swapping" of Controllers and views?
    Usually this is done by using a proxy server (net/http/httputil) or
    the process could pass the FD of the TCP Listener to the child process
    and stop receiving new connections.

    The child process would be running the up-to-date code.

    You could check goagain on godoc.org
    (http://godoc.org/github.com/rcrowley/goagain)


    --
    André Moraes
    http://amoraes.inf
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Sebastien Binet at Dec 16, 2014 at 8:29 am

    On Tue, Dec 16, 2014 at 8:36 AM, Rasmus Schultz wrote:
    So now, a year later, is there anything in the works for Go that will permit
    dynamic loading/unloading of code/modules?

    I think I heard or read something about DLL/SO support being in the works?
    there is. at least there is a proposal carefully crafted by Ian Lance Taylor:
    https://docs.google.com/document/d/1nr-TQHw_er6GOQRsF6T43GGhFDelrAP0NqSS_00RgZQ/preview?sle=true

    (as well as initial work from Elias, IIRC)

    -s

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Jesper Louis Andersen at Dec 16, 2014 at 8:33 am

    On Tue, Dec 16, 2014 at 8:36 AM, Rasmus Schultz wrote:
    So now, a year later, is there anything in the works for Go that will
    permit dynamic loading/unloading of code/modules?

    Out of curiosity, perhaps the more morbid kind of curiosity: what do you
    want to use it for? I'm well aware of the benefits of having the ability to
    inject code into a system while it is running, but I am always on the
    lookout for use cases which are new and interesting.


    --
    J.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Rasmus Schultz at Dec 16, 2014 at 12:31 pm
    Two things, sort of tangential.

    One is loading/unloading modular components of a web-application, e.g.
    dynamically recompiling/reloading on changes to source code. I know that
    Revel implements this by using a front controller that dispatches your
    application as a sub-process, but that means rebuilding the entire
    application, which in a large-scale modular architecture could become
    increasingly time-consuming.

    The other is to build a modular scripting language on top of Go - e.g.
    internally compiling things on the fly. And again, I know about e.g. gorun
    and the pattern it uses. What I'm looking for is something that has the
    quick turn-around life-cycle of scripting languages like PHP, e.g. with no
    full compile-stage, but instead transpiling to Go, compiling files to
    modules, reloading on change.

    On Tue, Dec 16, 2014 at 9:32 AM, Jesper Louis Andersen wrote:

    On Tue, Dec 16, 2014 at 8:36 AM, Rasmus Schultz wrote:

    So now, a year later, is there anything in the works for Go that will
    permit dynamic loading/unloading of code/modules?

    Out of curiosity, perhaps the more morbid kind of curiosity: what do you
    want to use it for? I'm well aware of the benefits of having the ability to
    inject code into a system while it is running, but I am always on the
    lookout for use cases which are new and interesting.


    --
    J.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedFeb 28, '13 at 7:02p
activeDec 16, '14 at 12:31p
posts15
users8
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase