Darwin port without CGO#39
Conversation
|
cool. someone, could please confirm this PR? I dont have mac. |
|
Tested work on my M1 Mac and is it enough? |
|
LGTM (on M1 iMac 24-inch) |
|
It looks fine on my macOS Catalina. No proxy settings: |
| httpsPort := C.CFNumberRef(C.CFDictionaryGetValue(cfDictProxy, unsafe.Pointer(C.kCFNetworkProxiesHTTPSPort))) | ||
|
|
||
| httpProxy := fmt.Sprintf("%s:%d", cfStringGetGoString(httpsHost), cfNumberGetGoInt(httpsPort)) | ||
| httpProxy := fmt.Sprintf("%s:%s", proxyMap["HTTPSProxy"], proxyMap["HTTPSPort"]) |
There was a problem hiding this comment.
It should be:
| httpProxy := fmt.Sprintf("%s:%s", proxyMap["HTTPSProxy"], proxyMap["HTTPSPort"]) | |
| httpProxy := net.JoinHostPort(proxyMap["HTTPSProxy"], proxyMap["HTTPSPort"]) |
shouldn't it?
It may not work with IPv6 addresses.
|
oops, I've forgotten pasting my code... My test code is: package main
import (
"fmt"
"github.com/mattn/go-ieproxy"
)
func main() {
conf := ieproxy.GetConf()
fmt.Printf("%#v\n", conf)
}go.mod is: |
|
The test passed. (on macOS Big Sur 11.6.5) |
|
@laurazard from a portability point of view, I would like to replace the darwin port with this implementation. is there a problem? |
|
I'd been meaning to do something like this since the previous issue came up! Nice! I'd like to test it a bit before it gets merged if that's alright @mattn, but other than that this is awesome :) If that's okay I'll look at it in a couple hours and post back. |
|
Looking at this, CGO is still required in the Please let me know if that's right 😅. I think the incremental change is good, although it doesn't fix the issue of requiring CGO to compile for darwin. @kazeburo ? |
|
Is this PR stuck? |
|
@chrislusf This PR does not fix completely issue that go-ieproxy on macOS uses cgo yet. |





Remove CGO dependencies from Darwin port. use scutil command and parse the result instead of using CGO.
I've tested in macOS Monterey.