Comments (3)
I don't think you could easily extend this to a state where it would be broadly useful. Most code depends upon other libraries, including the standard library. If you include, those things, then a feature needs to know how to translate those or somehow replace them with Typescript equivalents with often varying syntax or quirks that don't match Go. This isn't to say you can't do this, but it's far larger in scope than this project and should not be here. Luckily, nearly what you want also already exists in the form of gopherjs. I recommend you take a look at that project for transpiling Go to Javascript.
from typescriptify-golang-structs.
I would like to have functions as well, but in completely different way.
For example in go:
type MyService struct {
}
func (srv *MyService) Add(model MyModel) string {
id := db.Add(model);
return id
}
func (srv *MyService) Get(id string) MyModel {
model := db.Get(id);
return model
}
Results to:
export class MyService {
axios: any; // or any other http or rpc client
Add(model: MyModel): Promise<string> {
return axios.post("MyService/Add", { body: { model } });
}
Get(id: string): Promise<MyModel> {
return axios.post("MyService/Get", { body: { model } });
}
}
I have Wails app and I would like to generate services to call backend using one single route in which case instead of axios it would be some function to call the backend.
from typescriptify-golang-structs.
@fairking What you're suggesting is a solution for a completely different problem than the one this library solves. Also, it's highly dependant on the http library/framework you use.
But, generally, transpiling code is something I don't plan to implement because it is way too complicated and I don't have the time to mantain that.
from typescriptify-golang-structs.
Related Issues (20)
- time.Time no longer automatically converted to Date HOT 3
- Prefix affects map keys HOT 2
- Feature/ability to ignore certain structs and struct properties HOT 1
- YAML tag spport HOT 2
- Custom imports not included in generated file
- imports .: import cycle not allowed / Can`t handle package "." HOT 1
- Tool can't handle packages like ranked-model HOT 3
- Embedded struct with the same name produces same class HOT 3
- Error message to stderr HOT 3
- Nested Struct Won't Convert
- go 1.18 generics support HOT 1
- Struct Array Alias HOT 1
- output for pointers are always treated as `omitempty`
- Documentation comments HOT 3
- Add support for enums in the CLI tool HOT 1
- Doesn't work with vendoring
- Documentation for installation of CLI tool is incorrent
- Usage as a library HOT 1
- CamelCase option HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescriptify-golang-structs.