{"id":13840558,"url":"https://github.com/pkujhd/goloader","last_synced_at":"2025-05-15T13:05:37.403Z","repository":{"id":37705158,"uuid":"198358581","full_name":"pkujhd/goloader","owner":"pkujhd","description":"load and run golang code at runtime.","archived":false,"fork":false,"pushed_at":"2025-05-07T02:07:21.000Z","size":683,"stargazers_count":533,"open_issues_count":0,"forks_count":60,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-07T03:23:16.579Z","etag":null,"topics":["dynamic","go","golang","plugin"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pkujhd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-07-23T05:32:38.000Z","updated_at":"2025-05-07T02:07:24.000Z","dependencies_parsed_at":"2023-11-15T03:27:55.610Z","dependency_job_id":"ea979eb3-5fcb-4cb7-b82c-7b1bb62d0ff7","html_url":"https://github.com/pkujhd/goloader","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkujhd%2Fgoloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkujhd%2Fgoloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkujhd%2Fgoloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkujhd%2Fgoloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkujhd","download_url":"https://codeload.github.com/pkujhd/goloader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254346624,"owners_count":22055808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic","go","golang","plugin"],"created_at":"2024-08-04T17:00:50.352Z","updated_at":"2025-05-15T13:05:37.394Z","avatar_url":"https://github.com/pkujhd.png","language":"Go","funding_links":[],"categories":["Go","Go (531)"],"sub_categories":[],"readme":"\n# Goloader\n\n![Build Status](https://github.com/pkujhd/goloader/workflows/goloader%20Testing/badge.svg)\n\nGoloader can load and run Golang code at runtime.\n\nForked from **https://github.com/dearplain/goloader**, Take over maintenance because the original author is not in maintenance\n\n## How does it work?\n\nGoloader works like a linker: it relocates the address of symbols in an object file, generates runnable code, and then reuses the runtime function and the type pointer of the loader.\n\nGoloader provides some information to the runtime and gc of Go, which allows it to work correctly with them.\n\nPlease note that Goloader is not a scripting engine. It reads the output of Go compiler and makes them runnable. All features of Go are supported, and run just as fast and lightweight as native Go code.\n\n## Comparison with plugin\n\nGoloader reuses the Go runtime, which makes it much smaller. And code loaded by Goloader is unloadable.\n\nGoloader supports pprof tool(Yes, you can see code loaded by Goloader in pprof). \n\n## Build\n\n**Make sure you're using go \u003e= 1.8.**\n\nFirst, execute the following command, then do build and test. This is because Goloader relies on the internal package, which is forbidden by the Go compiler.\n```\n  cp -r $GOROOT/src/cmd/internal $GOROOT/src/cmd/objfile\n```\n\n## Examples\n\n#### Build Loader:\n\nIf use go version \u003e= 1.23\n```\n  go build --ldflags=\"-checklinkname=0\" github.com/pkujhd/goloader/examples/loader\n```\nIf use go version \u003c= 1.22\n```\n  go build github.com/pkujhd/goloader/examples/loader\n```\n\n\n#### Compile Object File and Run:\n\nIf use go module or go version \u003e= 1.20\n```\n  export GO111MODULE=on\n  go list -export -deps -f '{{if .Export}}packagefile {{.ImportPath}}={{.Export}}{{end}}' $GOPATH/src/github.com/pkujhd/goloader/examples/schedule/schedule.go \u003e importcfg\n  go tool compile -importcfg importcfg $GOPATH/src/github.com/pkujhd/goloader/examples/schedule/schedule.go\n  ./loader -o schedule.o -run main.main -times 10\n```\nIf use go path and go version \u003c 1.20\n```\n  export GO111MODULE=auto\n  go tool compile $GOPATH/src/github.com/pkujhd/goloader/examples/schedule/schedule.go\n  ./loader -o schedule.o -run main.main -times 10\n  \n  go tool compile $GOPATH/src/github.com/pkujhd/goloader/examples/base/base.go\n  ./loader -o base.o -run main.main\n  \n  go tool compile $GOPATH/src/github.com/pkujhd/goloader/examples/http/http.go\n  ./loader -o http.o -run main.main\n  \n  go install github.com/pkujhd/goloader/examples/basecontext\n  go tool compile -I $GOPATH/pkg/`go env GOOS`_`go env GOARCH`/ $GOPATH/src/github.com/pkujhd/goloader/examples/inter/inter.go\n  ./loader -o $GOPATH/pkg/`go env GOOS`_`go env GOARCH`/github.com/pkujhd/goloader/examples/basecontext.a:github.com/pkujhd/goloader/examples/basecontext -o inter.o\n```\n\n\n#### Build multiple go files\n```\n  go tool compile -I $GOPATH/pkg/`go env GOOS`_`go env GOARCH`/ -o test.o test1.go test2.go\n  ./loader -o test.o -run main.main\n```\n\n## Warning\n\nDon't use \"-s -w\" compile argument, It strips symbol table.\n\nDon't use \"go run\" and \"go test\" command, \"-s -w\" compile argument is default.\n\nThis has currently only been tested and developed on:\n\nGolang 1.8-1.24 (x64/x86, darwin, linux, windows)\n\nGolang 1.10-1.24 (arm, linux, android)\n\nGolang 1.8-1.24 (arm64, linux, android)\n\nGolang 1.16-1.24 (arm64, darwin)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkujhd%2Fgoloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkujhd%2Fgoloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkujhd%2Fgoloader/lists"}