{"id":29131867,"url":"https://github.com/kevyonan/sourcego","last_synced_at":"2025-12-15T00:57:00.359Z","repository":{"id":40300463,"uuid":"304754093","full_name":"kevyonan/SourceGo","owner":"kevyonan","description":"SourceGo is a transpiler that transforms a subset of Golang-like code to equivalent SourcePawn.","archived":false,"fork":false,"pushed_at":"2022-09-07T18:17:05.000Z","size":351,"stargazers_count":26,"open_issues_count":10,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-27T10:17:50.189Z","etag":null,"topics":["go","golang","transpiler"],"latest_commit_sha":null,"homepage":"https://forums.alliedmods.net/showthread.php?t=328269","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevyonan.png","metadata":{"files":{"readme":"README.md","changelog":"changes.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-16T22:50:13.000Z","updated_at":"2025-03-30T11:43:21.000Z","dependencies_parsed_at":"2023-01-17T18:45:14.856Z","dependency_job_id":null,"html_url":"https://github.com/kevyonan/SourceGo","commit_stats":null,"previous_names":["assyrianic/go2sourcepawn","kevyonan/sourcego","assyrianic/sourcego"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kevyonan/SourceGo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevyonan%2FSourceGo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevyonan%2FSourceGo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevyonan%2FSourceGo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevyonan%2FSourceGo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevyonan","download_url":"https://codeload.github.com/kevyonan/SourceGo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevyonan%2FSourceGo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262720641,"owners_count":23353448,"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":["go","golang","transpiler"],"created_at":"2025-06-30T06:05:00.270Z","updated_at":"2025-12-15T00:57:00.242Z","avatar_url":"https://github.com/kevyonan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SourceGo\nv1.4 beta\n\n## Introduction\n\n**SourceGo** is a transpiler that transforms a subset of Golang code to equivalent SourcePawn. The rationale behind SourceGo is to automate as much of the boilerplate possible when creating SourcePawn plugins.\n\n### Purpose\n\nTo increase SourcePawn plugin development time by using Golang's streamline engineered syntax.\n\n\n### Features\n\n* Abstracted common types into their own type classes such as `float[3]` aliasing as `Vec3`, etc.\nHere is the current types list and what params it abstracts to:\n```\nint     =\u003e int\nfloat   =\u003e float\nbool    =\u003e bool\n*[]char =\u003e char[]\nstring  =\u003e const char[]\n*string =\u003e char[]\nVec3    =\u003e const float[3]\n*Vec3   =\u003e float[3]\n```\n\n* Pattern matching\n\nArray/slice types will be automatically const unless passed by reference like: `*[]type`.\nSo having parameters such as `[]int` will be generated as `const int[]` while `*[]int` will be generated as `int[]`.\n\n\n* relative file imports are handled by using a dot `.` as the first letter\n```go\nimport \".file\"\n```\n\nBecomes:\n```c\n#include \"file\"\n```\n\n* Multiple return values are supported by mutating them into variable references.\n\n* Range loops for arrays:\n```go\nvar players [MAXPLAYERS+1]Entity\nfor index, player := range players {\n\t/// code;\n}\n```\n```c\nfor (int index = 0; index \u003c sizeof(players); index++)\n{\n\tint player = players[index];\n\t/// code;\n}\n```\n\n* Switch statements with and without an expression.\n```go\n// Go\nswitch x {\n\tcase 1, 2:\n\tdefault:\n}\n\nswitch {\n\tcase x \u003c 10, x+y \u003c 10.0:\n\t\t\n\tdefault:\n}\n```\n```sourcepawn\n/// SourcePawn\nswitch (x)\n{\n\tcase 1, 2:\n\t{\n\t}\n\tdefault:\n\t{\n\t}\n}\n\nif (x \u003c 10 || x+y \u003c 10.0)\n{\n}\nelse\n{\n}\n```\nExpression-less switchs are useful for a more compact if-else-if series.\n\n\n* Function pointer calls are broken down into manual Function API calling:\n```go\nfunc main() {\n\tCB := OnClientPutInServer\n\tfor i := 1; i\u003c=MaxClients; i++ {\n\t\tCB(i)\n\t}\n}\n\nfunc OnClientPutInServer(client Entity) {}\n```\nBecomes:\n```c\npublic void OnPluginStart() {\n\tFunction CB = OnClientPutInServer;\n\tfor (int i = 1; i \u003c= MaxClients; i++) {\n\t\tCall_StartFunction(null, CB);\n\t\tCall_PushCell(i);\n\t\tCall_Finish();\n\t}\n}\n\npublic void OnClientPutInServer(int client) {}\n```\n\n* Anonymous Functions (aka Function Literals) are supported:\n```go\nmy_timer := CreateTimer(2.0, func(timer Timer, data any) Action {\n\treturn Plugin_Continue\n}, 0, TIMER_REPEAT)\n```\n```sourcepawn\n/// SourcePawn\nHandle my_timer = CreateTimer(2.0, SrcGoFuncTemp1, 0, TIMER_REPEAT);\n...\npublic Action SrcGoFuncTemp1(Handle hTimer, any data)\n{\n\treturn Plugin_Continue;\n}\n```\n\n* Inline SourcePawn code using the builtin function `__sp__` - for those parts of SourcePawn that just can't be generated (like using new or making a methodmap from scratch).\n\n`__sp__` only takes a single string of raw SourcePawn code. Optionally, you can also use a named string constant (it will be generated into the resulting code file, so keep that in mind.)\n```go\n/// using raw string quotes here so that single \u0026 double quotes don't have to be escaped.\nvar kv KeyValues\n__sp__(`kv = new KeyValues(\"key_value\", \"key\", \"val\");`)\n\n...\n__sp__(`delete kv;`)\n```\n\n* `make` for _making_ dynamically sized, local arrays:\n```go\nmy_str := make([]char, size)\n```\nbecomes:\n```c\nchar[] my_str = new char[size];\n```\n\n### Planned Features\n* Generate Natives and Forwards with an include file for them.\n* Abstract, type-based syntax translation for higher data types like `StringMap` and `ArrayList`.\n* Handle-based Data Structures are abstracted into supportive syntax such where it's `value = Map[\"key\"]` instead of `map.GetValue(\"key\", value);`\n\n### Goal\nGenerate SourcePawn source code that is compileable by `spcomp` without having to modify/assist the generate source code.\n\n\n## Contributing\n\nTo submit a patch, file an issue and/or hit up a pull request.\n\n## Help\n\nCommand line options:\n* `--debug`, `-dbg` - prints the file's modified AST and pretty-printed version to a file for later checking.\n\n* `--force`, `-f` - forcefully generates a SourcePawn source code file, even if errors/issues occurred during transpilation.\n\n* `--help`, `-h` - Prints help list.\n\n* `--version` - Prints the version of SourceGo.\n\n* `--no-spcomp`, `-n` - Generates a SourcePawn source-code file without trying to invoke the SourcePawn compiler.\n\n* `--verbose`, `-v` - prints additional warnings.\n\nIf you need help or have any question, simply file an issue with **\\[HELP\\]** in the title.\n\n\n## Installation\n\n### Requirements\nLatest Golang version.\n\n## Credits\n\n* Nergal - main dev.\n\n## License\nThis project is licensed under MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevyonan%2Fsourcego","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevyonan%2Fsourcego","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevyonan%2Fsourcego/lists"}