{"_id":"@akoserwal/go-emitter","_rev":"4-1d02663e754011876ab5797fd81fa6aa","name":"@akoserwal/go-emitter","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@akoserwal/go-emitter","version":"1.0.0","keywords":["typespec","go","golang","codegen","code-generation","api","rest","http","client","sdk"],"author":{"name":"TypeSpec Community"},"license":"MIT","_id":"@akoserwal/go-emitter@1.0.0","maintainers":[{"name":"abhishek.koserwal","email":"abhishek.koserwal@gmail.com"}],"homepage":"https://github.com/typespec-community/typespec-go#readme","bugs":{"url":"https://github.com/typespec-community/typespec-go/issues"},"bin":{"go-emitter":"dist/cli/index.js"},"dist":{"shasum":"074c71fdbf977e0fb40547f172a3438427368054","tarball":"https://registry.npmjs.org/@akoserwal/go-emitter/-/go-emitter-1.0.0.tgz","fileCount":33,"integrity":"sha512-xZG9zQAAkL3XMDSnsCruHFOt84zUSDn38G9maYGWffyvmJu642qTzExkS/QjYyy8X0MM72ELmXRN0OlSUmlA9g==","signatures":[{"sig":"MEYCIQCXf77XYEkxkdY03q4zuEZybAtqNZqjzXVZfxTjBzXvVgIhAM4Fod+H9jtZgGr47h5mAB8b4Gwh4EnLkXAZC3HXM2db","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54180},"main":"dist/core/emitter.js","types":"./dist/core/emitter.d.ts","engines":{"node":">=16.0.0"},"gitHead":"9fe6f492cfcfd66e840be70c7b9174e43748bcef","scripts":{"dev":"tsc -w","lint":"eslint src --ext .ts --fix","test":"npm run build && npm run test:phases","build":"tsc","clean":"rm -rf dist tmp","format":"prettier --write src","quality":"npm run lint:check && npm run format:check && npm run type-check","clean-all":"npm run clean && rm -rf node_modules","test:unit":"npm run build && node -e \"console.log('Unit tests would run here')\"","lint:check":"eslint src --ext .ts","type-check":"tsc --noEmit","test:phase1":"node -e \"console.log('✅ Phase 1: Basic models work')\"","test:phase2":"node -e \"console.log('✅ Phase 2: Arrays, optionals, enums work')\"","test:phase3":"node -e \"console.log('✅ Phase 3: Interfaces, HTTP clients work')\"","test:phases":"npm run test:phase1 && npm run test:phase2 && npm run test:phase3","format:check":"prettier --check src","prepublishOnly":"npm run quality && npm run build && npm run test","test:integration":"npm run build && node dist/cli/index.js examples/ecommerce/api.tsp tmp/test-output.go"},"_npmUser":{"name":"abhishek.koserwal","email":"abhishek.koserwal@gmail.com"},"repository":{"url":"git+https://github.com/typespec-community/typespec-go.git","type":"git"},"_npmVersion":"10.8.3","description":"Clean, understandable Go code generator from TypeSpec definitions","directories":{},"_nodeVersion":"20.13.0","dependencies":{"commander":"^9.4.0"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.45.0","prettier":"^3.0.0","typescript":"^4.9.0","@types/node":"^18.0.0","eslint-plugin-import":"^2.27.5","eslint-config-prettier":"^8.8.0","@typescript-eslint/parser":"^6.0.0","@typescript-eslint/eslint-plugin":"^6.0.0"},"peerDependencies":{"@typespec/compiler":">=0.40.0"},"_npmOperationalInternal":{"tmp":"tmp/go-emitter_1.0.0_1775205102269_0.8321430864448771","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@akoserwal/go-emitter","version":"1.0.1","keywords":["typespec","go","golang","codegen","code-generation","api","rest","http","client","sdk"],"author":{"name":"TypeSpec Community"},"license":"MIT","_id":"@akoserwal/go-emitter@1.0.1","maintainers":[{"name":"abhishek.koserwal","email":"abhishek.koserwal@gmail.com"}],"homepage":"https://github.com/typespec-community/typespec-go#readme","bugs":{"url":"https://github.com/typespec-community/typespec-go/issues"},"bin":{"go-emitter":"dist/cli/index.js"},"dist":{"shasum":"de99cb0a6e3b290f1f1bb5bbca58d1898b12235e","tarball":"https://registry.npmjs.org/@akoserwal/go-emitter/-/go-emitter-1.0.1.tgz","fileCount":33,"integrity":"sha512-Um9wJlSutY6/4r8Ge2Y7M74Uux0KrtUc2vU1Oq3DcCttyggbPwLBitkrwFP2VAGhYSEYGU8hBmgxVs3gqe/n5A==","signatures":[{"sig":"MEUCICSBkAb92fqV6AFuzLjRnhNAG36tpPT70jrxEAAbBQ9DAiEAnLk/P1Q6VBugOxVseh2s2vZlOK+bHjM8OuKIi+LitBs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":56431},"main":"dist/core/emitter.js","types":"./dist/core/emitter.d.ts","engines":{"node":">=16.0.0"},"gitHead":"47048586463055e5383da0d97bee31d4d0dacaf1","scripts":{"dev":"tsc -w","lint":"eslint src --ext .ts --fix","test":"npm run build && npm run test:phases","build":"tsc","clean":"rm -rf dist tmp","format":"prettier --write src","quality":"npm run lint:check && npm run format:check && npm run type-check","clean-all":"npm run clean && rm -rf node_modules","test:unit":"npm run build && node -e \"console.log('Unit tests would run here')\"","lint:check":"eslint src --ext .ts","type-check":"tsc --noEmit","test:phase1":"node -e \"console.log('✅ Phase 1: Basic models work')\"","test:phase2":"node -e \"console.log('✅ Phase 2: Arrays, optionals, enums work')\"","test:phase3":"node -e \"console.log('✅ Phase 3: Interfaces, HTTP clients work')\"","test:phases":"npm run test:phase1 && npm run test:phase2 && npm run test:phase3","format:check":"prettier --check src","prepublishOnly":"npm run quality && npm run build && npm run test","test:integration":"npm run build && node dist/cli/index.js examples/ecommerce/api.tsp tmp/test-output.go"},"_npmUser":{"name":"abhishek.koserwal","email":"abhishek.koserwal@gmail.com"},"repository":{"url":"git+https://github.com/typespec-community/typespec-go.git","type":"git"},"_npmVersion":"10.8.3","description":"Clean, understandable Go code generator from TypeSpec definitions","directories":{},"_nodeVersion":"20.13.0","dependencies":{"commander":"^9.4.0"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.45.0","prettier":"^3.0.0","typescript":"^4.9.0","@types/node":"^18.0.0","eslint-plugin-import":"^2.27.5","eslint-config-prettier":"^8.8.0","@typescript-eslint/parser":"^6.0.0","@typescript-eslint/eslint-plugin":"^6.0.0"},"peerDependencies":{"@typespec/compiler":">=0.40.0"},"_npmOperationalInternal":{"tmp":"tmp/go-emitter_1.0.1_1775206328831_0.43301235011129613","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@akoserwal/go-emitter","version":"1.0.2","keywords":["typespec","go","golang","codegen","code-generation","api","rest","http","client","sdk"],"author":{"name":"TypeSpec Community"},"license":"MIT","_id":"@akoserwal/go-emitter@1.0.2","maintainers":[{"name":"abhishek.koserwal","email":"abhishek.koserwal@gmail.com"}],"homepage":"https://github.com/typespec-community/typespec-go#readme","bugs":{"url":"https://github.com/typespec-community/typespec-go/issues"},"bin":{"go-emitter":"dist/cli/index.js"},"dist":{"shasum":"99b10d46c63b8076554916b10ce7bfafc28720c3","tarball":"https://registry.npmjs.org/@akoserwal/go-emitter/-/go-emitter-1.0.2.tgz","fileCount":33,"integrity":"sha512-ranu+24ePZWvhU4Lgi4QP+0+B2dkuMOs7TC8ilvSg6nAr5wHu21OvMNEetKwZQhHtHtF7xFeG1Ta9EYHK2jx9w==","signatures":[{"sig":"MEUCIAx0ePeqW8ZtdwJlkW8I8Q1Q6WlE0HZWk24EQDKyw0/FAiEA2DUgHt/GOl8olE+hlEHLlKozZANEujNLxaOSzjT+wY4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":62440},"main":"dist/core/emitter.js","types":"./dist/core/emitter.d.ts","engines":{"node":">=16.0.0"},"gitHead":"37d45063d30f681d5f4586e100899b13a1f3e60e","scripts":{"dev":"tsc -w","lint":"eslint src --ext .ts --fix","test":"npm run build && npm run test:phases","build":"tsc","clean":"rm -rf dist tmp","format":"prettier --write src","quality":"npm run lint:check && npm run format:check && npm run type-check","clean-all":"npm run clean && rm -rf node_modules","test:unit":"npm run build && node -e \"console.log('Unit tests would run here')\"","lint:check":"eslint src --ext .ts","type-check":"tsc --noEmit","test:phase1":"node -e \"console.log('✅ Phase 1: Basic models work')\"","test:phase2":"node -e \"console.log('✅ Phase 2: Arrays, optionals, enums work')\"","test:phase3":"node -e \"console.log('✅ Phase 3: Interfaces, HTTP clients work')\"","test:phases":"npm run test:phase1 && npm run test:phase2 && npm run test:phase3","format:check":"prettier --check src","prepublishOnly":"npm run quality && npm run build && npm run test","test:integration":"npm run build && node dist/cli/index.js examples/ecommerce/api.tsp tmp/test-output.go"},"_npmUser":{"name":"abhishek.koserwal","email":"abhishek.koserwal@gmail.com"},"repository":{"url":"git+https://github.com/typespec-community/typespec-go.git","type":"git"},"_npmVersion":"10.8.3","description":"Clean, understandable Go code generator from TypeSpec definitions","directories":{},"_nodeVersion":"20.13.0","dependencies":{"commander":"^9.4.0"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.45.0","prettier":"^3.0.0","typescript":"^4.9.0","@types/node":"^18.0.0","eslint-plugin-import":"^2.27.5","eslint-config-prettier":"^8.8.0","@typescript-eslint/parser":"^6.0.0","@typescript-eslint/eslint-plugin":"^6.0.0"},"peerDependencies":{"@typespec/compiler":">=0.40.0"},"_npmOperationalInternal":{"tmp":"tmp/go-emitter_1.0.2_1775550457726_0.5749633685035891","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@akoserwal/go-emitter","version":"1.1.0","description":"Clean, understandable Go code generator from TypeSpec definitions","main":"dist/core/emitter.js","bin":{"go-emitter":"dist/cli/index.js"},"scripts":{"build":"tsc","dev":"tsc -w","test":"npm run build && jest","test:unit":"npm run build && jest --testPathPattern=test/unit","test:integration":"npm run build && jest --testPathPattern=test/integration","test:coverage":"npm run build && jest --coverage","test:watch":"jest --watch","lint":"eslint src --ext .ts --fix","lint:check":"eslint src --ext .ts","format":"prettier --write src","format:check":"prettier --check src","type-check":"tsc --noEmit","quality":"npm run lint:check && npm run format:check && npm run type-check","prepublishOnly":"npm run quality && npm run build && npm run test","clean":"rm -rf dist tmp","clean-all":"npm run clean && rm -rf node_modules"},"keywords":["typespec","go","golang","codegen","code-generation","api","rest","http","client","sdk"],"author":{"name":"TypeSpec Community"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/typespec-community/typespec-go.git"},"bugs":{"url":"https://github.com/typespec-community/typespec-go/issues"},"homepage":"https://github.com/typespec-community/typespec-go#readme","engines":{"node":">=16.0.0"},"dependencies":{"commander":"^9.4.0"},"devDependencies":{"@types/jest":"^30.0.0","@types/node":"^18.0.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","eslint":"^8.45.0","eslint-config-prettier":"^8.8.0","eslint-plugin-import":"^2.27.5","jest":"^30.3.0","prettier":"^3.0.0","ts-jest":"^29.4.9","typescript":"^4.9.0"},"peerDependencies":{"@typespec/compiler":">=0.40.0"},"_id":"@akoserwal/go-emitter@1.1.0","gitHead":"1fc9a2e3561b11dd0bc63ad1c309a12e557b9560","types":"./dist/core/emitter.d.ts","_nodeVersion":"20.13.0","_npmVersion":"10.8.3","dist":{"integrity":"sha512-ZoW5LxdQK2dqd9xICSCnUabVRFPXvw3P4vzCO9fF4jIR4rl+hFM0LxtlcbgHLICaSu9gdkkNNNxAWBdOtXJLkg==","shasum":"a53bf5062b5348c6c1e3fc713b2a9180f6fabcdd","tarball":"https://registry.npmjs.org/@akoserwal/go-emitter/-/go-emitter-1.1.0.tgz","fileCount":36,"unpackedSize":124781,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEqNwLebZ9dlEwIBQr4E7ru3ZGcobVfU1beqMbbQ6yixAiEAqv2LegyBQuO3BsezC234u4zjKI6rYw8CBOXkTfI2q8s="}]},"_npmUser":{"name":"abhishek.koserwal","email":"abhishek.koserwal@gmail.com"},"directories":{},"maintainers":[{"name":"abhishek.koserwal","email":"abhishek.koserwal@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/go-emitter_1.1.0_1775726758717_0.49603214491944025"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-03T08:31:42.164Z","modified":"2026-04-09T09:25:58.988Z","1.0.0":"2026-04-03T08:31:42.460Z","1.0.1":"2026-04-03T08:52:08.967Z","1.0.2":"2026-04-07T08:27:37.846Z","1.1.0":"2026-04-09T09:25:58.857Z"},"bugs":{"url":"https://github.com/typespec-community/typespec-go/issues"},"author":{"name":"TypeSpec Community"},"license":"MIT","homepage":"https://github.com/typespec-community/typespec-go#readme","keywords":["typespec","go","golang","codegen","code-generation","api","rest","http","client","sdk"],"repository":{"type":"git","url":"git+https://github.com/typespec-community/typespec-go.git"},"description":"Clean, understandable Go code generator from TypeSpec definitions","maintainers":[{"name":"abhishek.koserwal","email":"abhishek.koserwal@gmail.com"}],"readme":"# TypeSpec Go Emitter\n\n[![npm version](https://badge.fury.io/js/@akoserwal/go-emitter.svg)](https://www.npmjs.com/package/@akoserwal/go-emitter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA Go code generator for TypeSpec definitions.\n\n## 📦 Installation\n\n```bash\nnpm install -g @akoserwal/go-emitter\n```\n\n## 🚀 Quick Start\n\n```bash\n# Generate Go code from TypeSpec\ngo-emitter api.tsp client.go\n\n# With configuration\ngo-emitter api.tsp client.go -c config/client.json\n\n# Watch mode\ngo-emitter api.tsp client.go -w\n```\n\n## 🏗️ Architecture\n\n```\nsrc/\n├── types/           # Type definitions\n├── core/\n│   ├── parser.ts    # TypeSpec parsing (regex-based)\n│   ├── type-mapper.ts   # Type system mapping\n│   └── emitter.ts   # Main orchestration\n├── generators/\n│   ├── go-struct.ts     # Go struct generation\n│   ├── go-enum.ts       # Go enum generation\n│   ├── go-interface.ts  # Go interface generation\n│   └── go-union.ts      # Go union generation\n└── cli/\n    └── index.ts     # Command-line interface\n```\n\n## 📝 Example\n\n**Input (`api.tsp`):**\n```typescript\nenum Status { Active, Inactive }\n\nmodel User {\n  id: int64;\n  name: string;\n  email?: string;\n  status: Status;\n}\n\ninterface UserService {\n  getUser(id: int64): User;\n  createUser(user: User): User;\n}\n```\n\n**Config (`config.json`):**\n```json\n{\n  \"packageName\": \"client\",\n  \"generateHTTPClient\": true\n}\n```\n\n**Output (`client.go`):**\n```go\npackage client\n\nimport (\n    \"fmt\"\n    \"encoding/json\"\n    \"net/http\"\n    \"context\"\n)\n\ntype Status int\n\nconst (\n    StatusActive Status = iota\n    StatusInactive\n)\n\nfunc (e Status) String() string {\n    switch e {\n    case StatusActive:\n        return \"Active\"\n    case StatusInactive:\n        return \"Inactive\"\n    default:\n        return \"Unknown\"\n    }\n}\n\ntype UserService interface {\n    GetUser(ctx context.Context, id int64) (User, error)\n    CreateUser(ctx context.Context, user User) (User, error)\n}\n\ntype UserServiceClient struct {\n    baseURL string\n    httpClient *http.Client\n}\n\nfunc NewUserServiceClient(baseURL string) *UserServiceClient {\n    return &UserServiceClient{\n        baseURL: baseURL,\n        httpClient: &http.Client{},\n    }\n}\n\nfunc (c *UserServiceClient) GetUser(ctx context.Context, id int64) (User, error) {\n    var result User\n    url := fmt.Sprintf(\"%s/getUser\", c.baseURL)\n    req, err := http.NewRequestWithContext(ctx, \"GET\", url, nil)\n    if err != nil {\n        return result, err\n    }\n    req.Header.Set(\"Accept\", \"application/json\")\n\n    resp, err := c.httpClient.Do(req)\n    if err != nil {\n        return result, err\n    }\n    defer resp.Body.Close()\n\n    if resp.StatusCode != http.StatusOK {\n        return result, fmt.Errorf(\"HTTP error: %d\", resp.StatusCode)\n    }\n\n    if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {\n        return result, err\n    }\n    return result, nil\n}\n\nfunc (c *UserServiceClient) CreateUser(ctx context.Context, user User) (User, error) {\n    var result User\n    // TODO: Implement HTTP POST request to /createUser\n    return result, nil\n}\n\ntype User struct {\n    Id int64 `json:\"id\"`\n    Name string `json:\"name\"`\n    Email *string `json:\"email\"`\n    Status Status `json:\"status\"`\n}\n\nfunc NewUser(id int64, name string, status Status) *User {\n    return &User{\n        Id: id,\n        Name: name,\n        Status: status,\n    }\n}\n```\n\n## ⚙️ Configuration\n\n**Presets available:**\n- `config/default.json` - Minimal setup\n- `config/client.json` - HTTP clients with validation\n- `config/models.json` - Models with builders\n\n**Custom config:**\n```json\n{\n  \"packageName\": \"myapi\",\n  \"imports\": [\"fmt\", \"encoding/json\"],\n  \"generateValidation\": true,\n  \"generateHTTPClient\": true,\n  \"generateTests\": true\n}\n```\n\n## 🎨 Features\n\n| Feature | Status | Example |\n|---------|--------|---------|\n| **Enums** | ✅ | `enum Status { Active }` → `const StatusActive = iota` |\n| **Models** | ✅ | `model User { name: string }` → `type User struct` |\n| **Arrays** | ✅ | `tags: string[]` → `Tags []string` |\n| **Maps** | ✅ | `Record<string, int>` → `map[string]int` |\n| **Optionals** | ✅ | `email?: string` → `Email *string` |\n| **Interfaces** | ✅ | `interface API {}` → Go interfaces |\n| **HTTP Clients** | ✅ | Real REST client implementations |\n| **Validation** | ✅ | `Validate() error` methods |\n| **JSON** | ✅ | `ToJSON()` / `FromJSON()` helpers |\n\n## 📊 Development\n\n```bash\n# Build\nnpm run build\n\n# Test\nnpm test\n\n# Format\nnpm run format\n\n# Lint\nnpm run lint\n\n# Quality check\nnpm run quality\n```\n\n## 📁 Examples\n\nSee `examples/` for real-world TypeSpec definitions:\n- **E-commerce API** - Complex models, validation\n- **Blog API** - CRUD operations\n- **User Management** - Authentication, RBAC\n\n## 🤝 Contributing\n\nWe welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for:\n- Code quality standards\n- Architecture decisions\n- Development workflow\n\n## 📄 License\n\nMIT License - see [LICENSE](LICENSE) file.\n\n---\n","readmeFilename":"README.md"}