-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: create local proxy library that is Go Mobile-friendly #64
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, added some comments.
x/examples/mobileproxy/.gitignore
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this? It seems we don't have any actual code generating this folder, the only place we mentioned it is in the document. I feel it's OK to un-track it if it's only generated in a documentation, and we already mentioned how to clean it up in the doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another look?
x/examples/mobileproxy/README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about moving this to x/appproxy and call it x/mobileproxy, so it's clear it's for Go Mobile?
x/appproxy shouldn't really be used by Go code, since it has a limited API that is not really optimal for Go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I updated the PR to have everything in x/mobileproxy
. This way we can keep the library as clearly intended for Go Mobile.
|
||
### Build the iOS and Android libraries with [`gomobile bind`](https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile#hdr-Build_a_library_for_Android_and_iOS) | ||
|
||
```bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add a TODO to publish these to Swift packages/maven?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Providing a wrapper library would be better than documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is definitely something that will help and we should consider. The downside is that it will require a releases process. Let's see how people end up using it and think about where we would put the binaries. To be defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's why I said we should at least track it with a TODO, or maybe an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I don't want to set the expectation that we will be providing the pre-packaged libraries. I want to see if what we have here will be good enough first, and we can consider the next step if people keep struggling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is every TODO or thing in the backlog something we're committing to definitely doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for not having a TODO for the release is that we are not currently intending to do it. Adding a TODO to a README file will set the wrong expectation. It's different from a code TODO.
We've been keeping the roadmap in the root README.
x/mobileproxy/README.md
Outdated
Note: Gomobile expects gobind to be in the PATH, that's why we need to prebuild it, and set up the PATH accordingly. | ||
|
||
<details> | ||
<summary>iOS generated Code</summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unclear to me why this is in here. Won't this diverge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is to make it clearer what the actual mobile interfaces look like, since that's what people will be using. It clarifies what the output is too.
It shouldn't diverge if we don't change the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but why not commit the files and then just link to them? And generate them in pre-commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Committing generated code is generally bad practice, as it diverges and it's hard to tell where the generated file came from. The releases, if we decide to do them, will include the binaries and header files.
The goal of having the code here is educational, so people know what the native library looks like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you're committing generated code here? Why is it okay when you do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's just for illustration, it's not code to be used. People won't be copying and pasting it. They will run the commands in the README instead.
I've updated the text to say "Sample" code to make it clear that may not be the actual code to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe adding "for reference", or "do not use in production" warning before the code snippet would make it more clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment and a warning.
Note that there's no risk in accidentally using this in production, since you actually need the XCFramework/AAR with the binaries in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the code looks good, added a few nit-picking comments.
|
||
### Build the iOS and Android libraries with [`gomobile bind`](https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile#hdr-Build_a_library_for_Android_and_iOS) | ||
|
||
```bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Providing a wrapper library would be better than documentation.
In this PR:
x/appproxy
library that runs a local proxy given an address and configx/examples/fetch-proxy
that illustrates the pattern of running a local proxy and configuring a networking library.x/examples/mobileproxy
, which illustrates how to build the local proxy library for mobile.