{"id":29720976,"url":"https://github.com/willibrandon/windowsservice","last_synced_at":"2025-07-24T14:15:01.088Z","repository":{"id":305630391,"uuid":"1023409308","full_name":"willibrandon/windowsservice","owner":"willibrandon","description":"Pure Go Windows service implementation with zero dependencies","archived":false,"fork":false,"pushed_at":"2025-07-21T06:53:19.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-21T08:15:08.911Z","etag":null,"topics":["go","golang","scm","service","service-manager","syscall","win32","windows","windows-api","windows-service"],"latest_commit_sha":null,"homepage":"","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/willibrandon.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":"2025-07-21T06:00:54.000Z","updated_at":"2025-07-21T06:52:54.000Z","dependencies_parsed_at":"2025-07-21T08:15:38.102Z","dependency_job_id":"303888e9-aa7c-4dbd-aa5b-011f4718a637","html_url":"https://github.com/willibrandon/windowsservice","commit_stats":null,"previous_names":["willibrandon/windowsservice"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/willibrandon/windowsservice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2Fwindowsservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2Fwindowsservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2Fwindowsservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2Fwindowsservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willibrandon","download_url":"https://codeload.github.com/willibrandon/windowsservice/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2Fwindowsservice/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266854732,"owners_count":23995489,"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-07-24T02:00:09.469Z","response_time":99,"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","golang","scm","service","service-manager","syscall","win32","windows","windows-api","windows-service"],"created_at":"2025-07-24T14:14:58.671Z","updated_at":"2025-07-24T14:15:01.080Z","avatar_url":"https://github.com/willibrandon.png","language":"Go","readme":"# windowsservice\n\n[![Test](https://github.com/willibrandon/windowsservice/actions/workflows/test.yml/badge.svg)](https://github.com/willibrandon/windowsservice/actions/workflows/test.yml)\n[![Go Reference](https://pkg.go.dev/badge/github.com/willibrandon/windowsservice.svg)](https://pkg.go.dev/github.com/willibrandon/windowsservice)\n\nPure Go Windows service implementation with zero dependencies.\n\n## Installation\n\n```bash\ngo get github.com/willibrandon/windowsservice\n```\n\n## Usage\n\n```go\npackage main\n\nimport \"github.com/willibrandon/windowsservice\"\n\nfunc main() {\n    start := func() {\n        // Your service logic here\n        for {\n            doWork()\n        }\n    }\n    \n    stop := func() {\n        // Cleanup\n    }\n    \n    windowsservice.Run(start, stop)\n}\n```\n\n## Running\n\n### Console Mode\n\n```bash\ngo run .\n```\n\n### Service Mode\n\n```powershell\n# Build\ngo build -o myservice.exe\n\n# Install\nsc create MyService binPath= \"C:\\path\\to\\myservice.exe\"\n\n# Start\nsc start MyService\n\n# Stop\nsc stop MyService\n\n# Delete\nsc delete MyService\n```\n\n## Testing\n\nRequires Administrator privileges:\n\n```bash\ngo test -v ./...\n```\n\n## Implementation Details\n\nThe service uses direct Windows syscalls to `advapi32.dll` and `kernel32.dll` for SCM integration. No CGO or external dependencies required.\n\n### Service Detection\n\nAutomatically detects execution context:\n- Console: Runs directly for debugging\n- Service: Integrates with Windows Service Control Manager\n\n### Status Reporting\n\nProperly reports service states:\n- `SERVICE_RUNNING`\n- `SERVICE_STOP_PENDING` \n- `SERVICE_STOPPED`\n\n## Example\n\nSee [examples/heartbeat](examples/heartbeat) for a complete example that writes heartbeat timestamps to demonstrate service lifecycle.\n\n## License\n\n[MIT](LICENSE)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillibrandon%2Fwindowsservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillibrandon%2Fwindowsservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillibrandon%2Fwindowsservice/lists"}