A package you import could be using cgo, you don't have to be using it 
directly.
If you run `GOOS=linux go build` on a mac, that is cross compileing and cgo 
is disabled by default.
You can try `CGO_ENABLED=0 go build` and if it works then it is cgo related.

>From the error messages, it looks like a package for using a SMC or other 
hardware.
On Monday, 22 March 2021 at 9:02:36 pm UTC+8 max...@gmail.com wrote:

> But I didn't write cgo code in my project. 
> The weird part is I can build success with *GOOS=linux go build*, but 
> failed with *GOOS=darwin go build*
>
> On Friday, March 19, 2021 at 5:11:57 AM UTC+8 Ian Lance Taylor wrote:
>
>> On Thu, Mar 18, 2021 at 9:55 AM Max Xu <max...@gmail.com> wrote:
>> >
>> > I'm running into a weird bug:
>> >
>> > Failed with command:
>> > GOOS=darwin go build
>> >
>> > Bug success with:
>> > GOOS=linux go build
>> >
>> > The failed Message:
>> >
>> > /usr/local/opt/go/libexec/pkg/tool/darwin_amd64/link: running clang 
>> failed: exit status 1
>> > duplicate symbol '_readdrivestat' in:
>> > 
>> /var/folders/tx/5c8vkq6x2k1f5nqvbj271qyc0000gn/T/go-link-162098608/000011.o
>> > 
>> /var/folders/tx/5c8vkq6x2k1f5nqvbj271qyc0000gn/T/go-link-162098608/000036.o
>> > duplicate symbol '_get_temperature' in:
>> > 
>> /var/folders/tx/5c8vkq6x2k1f5nqvbj271qyc0000gn/T/go-link-162098608/000014.o
>> > 
>> /var/folders/tx/5c8vkq6x2k1f5nqvbj271qyc0000gn/T/go-link-162098608/000039.o
>> > duplicate symbol '_open_smc' in:
>> > 
>> /var/folders/tx/5c8vkq6x2k1f5nqvbj271qyc0000gn/T/go-link-162098608/000014.o
>> > 
>> /var/folders/tx/5c8vkq6x2k1f5nqvbj271qyc0000gn/T/go-link-162098608/000039.o
>> > duplicate symbol '_close_smc' in:
>> > 
>> /var/folders/tx/5c8vkq6x2k1f5nqvbj271qyc0000gn/T/go-link-162098608/000014.o
>> > 
>> /var/folders/tx/5c8vkq6x2k1f5nqvbj271qyc0000gn/T/go-link-162098608/000039.o
>> > ld: 4 duplicate symbols for architecture x86_64
>> > clang: error: linker command failed with exit code 1 (use -v to see 
>> invocation)
>>
>> Hard to say without seeing the code, but my first guess would be
>> erroneous cgo code. It looks like you have multiple cases of cgo code
>> that are defining the same symbol in the C preamble without declaring
>> it as `static`.
>>
>> Ian
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/effcc88f-2465-4877-a237-451ed4271f48n%40googlegroups.com.

Reply via email to