{"id":17993880,"url":"https://github.com/timandy/gohack","last_synced_at":"2025-08-04T03:36:36.325Z","repository":{"id":37280097,"uuid":"478456726","full_name":"timandy/gohack","owner":"timandy","description":"A powerful reflect library.","archived":false,"fork":false,"pushed_at":"2024-11-25T00:41:56.000Z","size":58,"stargazers_count":9,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T18:01:35.048Z","etag":null,"topics":["go","goid","golang","labels","paniconfault","reflect","runtime","runtime-g"],"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/timandy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-06T07:47:52.000Z","updated_at":"2024-09-05T21:41:26.000Z","dependencies_parsed_at":"2024-02-20T10:26:58.708Z","dependency_job_id":"3bcdc266-57ba-4a2a-8634-e00392b13dc4","html_url":"https://github.com/timandy/gohack","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/timandy/gohack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timandy%2Fgohack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timandy%2Fgohack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timandy%2Fgohack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timandy%2Fgohack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timandy","download_url":"https://codeload.github.com/timandy/gohack/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timandy%2Fgohack/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268644915,"owners_count":24283395,"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","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["go","goid","golang","labels","paniconfault","reflect","runtime","runtime-g"],"created_at":"2024-10-29T20:13:20.940Z","updated_at":"2025-08-04T03:36:36.271Z","avatar_url":"https://github.com/timandy.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gohack\n\n[![Build Status](https://github.com/timandy/gohack/actions/workflows/build.yml/badge.svg)](https://github.com/timandy/gohack/actions)\n[![Codecov](https://codecov.io/gh/timandy/gohack/branch/main/graph/badge.svg)](https://app.codecov.io/gh/timandy/gohack)\n[![Go Report Card](https://goreportcard.com/badge/github.com/timandy/gohack)](https://goreportcard.com/report/github.com/timandy/gohack)\n[![License](https://img.shields.io/github/license/timandy/gohack.svg)](https://github.com/timandy/gohack/blob/main/LICENSE)\n\n\u003e [中文版](README_zh.md)\n\n`gohack` provides a design and source code with which you can `read` and `modify` arbitrary fields of the coroutine struct `runtime.g`, even the contents of other structs not exported by the runtime.\n\n# Introduce\n\n`gohack` gets the unexported structure type by looking up the runtime symbol table `typelinks`, which can get the field offset of the struct.\n\nWhen the fields of other variables of this type are to be read, only the address is obtained through another simplified assembly, which has low overhead, and offsets the address and then reads and writes the content.\n\nThis library demonstrates how to get the type `runtime.g` and get the offset of the key field.\n\nThen read the address of the current coroutine structure `runtime.g`, offset the pointer address, and then read and write the fields.\n\nIt should be noted that this method has minimal overhead, is compatible with future `go` versions, and supports cross-platform (`386`, `amd64`, `armv6`, `armv7`, `arm64`, `loong64`, `mips`, `mipsle`, `mips64`, `mips64le`, `ppc64`, `ppc64le`, `riscv64`, `s390x`, `wasm`).\n\n## Usage\n\n`gohack` does not provide any exposed interface.\n\nThe goal of `gohack` is to provide an idea and source code implementation.\n\nIf you feel this repository is helpful to you, please [Fork](https://github.com/timandy/gohack/fork) and [Star](https://github.com/timandy/gohack).\n\n[routine](https://github.com/timandy/routine) is a `tls` library, powered by `gohack`.\n\n# Support Grid\n\n|                | **`darwin`** | **`linux`** | **`windows`** | **`freebsd`** | **`js`** |                |\n|---------------:|:------------:|:-----------:|:-------------:|:-------------:|:--------:|:---------------|\n|      **`386`** |              |      ✅      |       ✅       |       ✅       |          | **`386`**      |\n|    **`amd64`** |      ✅       |      ✅      |       ✅       |       ✅       |          | **`amd64`**    |\n|    **`armv6`** |              |      ✅      |               |               |          | **`armv6`**    |\n|    **`armv7`** |              |      ✅      |               |               |          | **`armv7`**    |\n|    **`arm64`** |      ✅       |      ✅      |               |               |          | **`arm64`**    |\n|  **`loong64`** |              |      ✅      |               |               |          | **`loong64`**  |\n|     **`mips`** |              |      ✅      |               |               |          | **`mips`**     |\n|   **`mipsle`** |              |      ✅      |               |               |          | **`mipsle`**   |\n|   **`mips64`** |              |      ✅      |               |               |          | **`mips64`**   |\n| **`mips64le`** |              |      ✅      |               |               |          | **`mips64le`** |\n|    **`ppc64`** |              |      ✅      |               |               |          | **`ppc64`**    |\n|  **`ppc64le`** |              |      ✅      |               |               |          | **`ppc64le`**  |\n|  **`riscv64`** |              |      ✅      |               |               |          | **`riscv64`**  |\n|    **`s390x`** |              |      ✅      |               |               |          | **`s390x`**    |\n|     **`wasm`** |              |             |               |               |    ✅     | **`wasm`**     |\n|                | **`darwin`** | **`linux`** | **`windows`** | **`freebsd`** | **`js`** |                |\n\n✅: Supported\n\n# *License*\n\n`gohack` is released under the [Apache License 2.0](LICENSE).\n\n```\nCopyright 2021-2024 TimAndy\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimandy%2Fgohack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimandy%2Fgohack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimandy%2Fgohack/lists"}