All Projects → got-reload → Got Reload

got-reload / Got Reload

Licence: bsd-3-clause
Reload Go code in a running process at function/method level granularity, using Yaegi

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Got Reload

Filtrex
A library for performing and validating complex filters from a client (e.g. smart filters)
Stars: ✭ 157 (+441.38%)
Mutual labels:  parsing, filter
Jekyll Liquify
A Jekyll filter that parses Liquid from front matter
Stars: ✭ 21 (-27.59%)
Mutual labels:  filter
Systemjs Hmr
Hot Module Replacement for SystemJS
Stars: ✭ 24 (-17.24%)
Mutual labels:  hot-reload
Fsharp Data Processing Pipeline
Provides an extensible solution for creating Data Processing Pipelines in F#.
Stars: ✭ 13 (-55.17%)
Mutual labels:  filter
Cr
cr.h: A Simple C Hot Reload Header-only Library
Stars: ✭ 845 (+2813.79%)
Mutual labels:  hot-reload
Fsvideoview
An easy video playback view for iOS
Stars: ✭ 14 (-51.72%)
Mutual labels:  filter
Samovar
Stars: ✭ 23 (-20.69%)
Mutual labels:  parsing
Citadelcore
Cross platform filtering HTTP/S proxy based on .NET Standard 2.0.
Stars: ✭ 28 (-3.45%)
Mutual labels:  filter
Pornlist
Ad-blocking porn websites filter list for Adblock Plus and uBlock Origin.
Stars: ✭ 21 (-27.59%)
Mutual labels:  filter
Django Suit Daterange Filter
Filter for django-admin allowing lookups by date range
Stars: ✭ 13 (-55.17%)
Mutual labels:  filter
Disposable Email Domains
a list of disposable and temporary email address domains
Stars: ✭ 873 (+2910.34%)
Mutual labels:  filter
Librestreaming
Android real-time effect filter rtmp streaming library.using Mediacodec HWencoding&librtmp stream.
Stars: ✭ 856 (+2851.72%)
Mutual labels:  filter
Ng2 Flex Table
Angular 4 Table - Beautiful Table especially made for non-relational databases. With inline editing, column search & filter and fixed headers.
Stars: ✭ 15 (-48.28%)
Mutual labels:  filter
Probtopdf
Turn online textbook into Exam-friendly, offline, searchable PDF
Stars: ✭ 27 (-6.9%)
Mutual labels:  parsing
Comby
A tool for structural code search and replace that supports ~every language.
Stars: ✭ 912 (+3044.83%)
Mutual labels:  parsing
Eloquent Filter
This simple package helps you filter Eloquent data using query filters.
Stars: ✭ 24 (-17.24%)
Mutual labels:  filter
Svelte Redux Shopping Cart
Example Shopping Cart App using Svelte, Redux, and Webpack
Stars: ✭ 13 (-55.17%)
Mutual labels:  hot-reload
Webpack Dev Server
Serves a webpack app. Updates the browser on changes. Documentation https://webpack.js.org/configuration/dev-server/.
Stars: ✭ 7,250 (+24900%)
Mutual labels:  hot-reload
Hr4r
Example project - "Hot Reloading 4 RequireJS" front-end web applications & some extra code demonstrating hot-reloading for Node.js Express servers
Stars: ✭ 28 (-3.45%)
Mutual labels:  hot-reload
Hot Loader Demo
React Hot Loader 3 minimal demo
Stars: ✭ 27 (-6.9%)
Mutual labels:  hot-reload

got reload?

Function/method-level stateful hot reloading for Go!

Status

Very much work in progress. The usage of this tool changes pretty much daily as we iterate on it. That being said, it is usually usable for some definition of "usable."

Do you have a demo?

Clone this repo somewhere and do the following within the repo's root directory:

go run ./cmd/got-reload run -p github.com/got-reload/got-reload/demo/example ./demo/
# press enter a few times to see the method get invoked and to watch the
# package-level variable get incremented

In a different terminal, return to the original cloned repo and edit one of the function definitions in demo/example or demo/example2. For starters, just make it return a different constant.

You should see the running program discover the changes and reload the definition of the function. Press enter a few more times to watch the return value change.

Note how the package-level variable's state was not reset by the reload.

You can also try our Gio-based GUI live editing demo:

go run ./cmd/got-reload run -p github.com/got-reload/got-reload/giodemo/reloadable ./giodemo/

Try altering the layout function defined in ./giodemo/reloadable/reloadable.go. See the comments for ideas.

Inspiration

See this video that Chris did for something similar:

https://user-images.githubusercontent.com/2324697/106301108-4e2fce80-6225-11eb-8038-1d726b3eb269.mp4

How it works

Rewrite each function/method

We alter each function and method declaration in your code so that it invokes a package-level function variable. This allows us to redefine the implementation of your functions/methods at runtime.

The filter will transparently change functions from this

func Foo(... args ...) (...return values...) {
  // body
}

into this

func Foo(... args ...) (...return values...) {
  return GRLf_Foo(...args...)
}

var GRLf_Foo = func(...args...) (...return values...) {
   // body
}

func GRLset_Foo(f func(...Foo's signature)...) {
  GRLf_Foo = f
}

and similarly for methods.

Export all named private package-level variables, types, interfaces, and struct field names, by adding "GRL_" to the front.

(None of this is done in-place, it's all performed on a temporary copy of the packages being filtered. No original source code is changed.)

We watch your source for changes at runtime

When a filtered source file changes, it will be read, parsed, and changed functions will be installed with new versions of themselves via the generated GRLset_* functions, via Yaegi, a Go interpreter.

Limitations

  • Fundamental limitations

    • Does not support reloading packages that directly reference CGO symbols. You can still depend on packages that use CGO, just don't use any C.foo symbols in your reloadable code.
    • Cannot redefine functions that never return. If your whole program runs an event loop that iterates indefinitely over some channels, the new definition of that event loop function will never be invoked because the old one never returned.
    • Cannot redefine main or init functions (even if you could, it would have no effect. Your program has already started, so these functions have already executed.)
  • Current practical limitations (things we hope to eventually work around)

    • You cannot change function signatures.
    • You cannot redefine types (add/remove/change fields).
    • You cannot add new package-scope variables or constants during a reload (this should be easy to fix, just haven't gotten to it).
    • You cannot gain new module dependencies during a reload. That said, you can import any package that your module already imports transitively. So if X imports Y and you only import X, then you can later import Y without issue. You can also import any package in the standard library, which is already built-in to Yaegi.
    • You cannot reload any symbols in the main package. You can work around this by just copying your current main code to (for example) grl_main, exporting main as Main, and rewriting your real main to just call grl_main.Main(). Eventually we'll teach the filter how to do this for you. (Issue 5)

Who came up with this harebrained idea?

Given that Yaegi's been out for a while, and Go's parsing tools have been out since the beginning (well, a lot of them, anyway), we both wonder why nobody has done this yet, to be honest.

Can I use it now?

Yes? Kinda depends on your tolerance for jank and breaking changes. If you can survive the fact that the CLI may change on a daily basis, then sure!

Can I support the development of this tool?

Yes! We appreciate stars, watchers, feedback, and, of course, pull requests! A PR need not necessarily be code, of course; it could be documentation, or something else. Whatever itch you care to scratch.

You can also sponsor the developers:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].