Похожие чаты

Hey guys, Is it possible to compile a Go program to

a dynamic shared library?
dll extension for Windows and so for Linux I mean.

35 ответов

50 просмотров

why?

Raymond- Автор вопроса
Roman Sharkov
why?

LOL. For many reasons. To be used in a Rust program for example.

Raymond
LOL. For many reasons. To be used in a Rust progra...

what exactly is funny tho? calling Go from another language is near impossible (there are very hacky ways but you shouldn't do it in production) IPC is preferable

Raymond- Автор вопроса
Roman Sharkov
what exactly is funny tho? calling Go from another...

Your question was funny man. The reasons of using shared libraries are clear enough.

yes

Raymond- Автор вопроса
Raymond- Автор вопроса
A​kshit
yes

Can explain it? How can I do it?

Roman Sharkov
what exactly is funny tho? calling Go from another...

its not hacky at all :) you can literally use cgo exports and build with buildtype=c-shared or c-archive. then use the resulting dll / archive

Raymond
Why shouldn't we use it in production?

https://blog.filippo.io/rustgo/ here's an indepth article about it

Raymond
Why shouldn't we use it in production?

its mostly difficult and there are better methods like RPC, APIs or pub-sub queues, etc

Raymond
Can explain it? How can I do it?

1. you need cgo exports (please google this), and you need to compile with cgo enabled 2. build with buildmode=c-shared or c-archive and link it with anything. it will work with stuff that supports calling C functions

Anchit
its mostly difficult and there are better methods ...

those are for servers, sometimes you need to go it on the client side for example for a gui application

Roman Sharkov
cgo != Go

not actual C, just exporting go functions for use with C like you do with cgo

A​kshit
those are for servers, sometimes you need to go it...

yes, a GUI application can start two different processes. Those details will be invisible to the user

Raymond- Автор вопроса
Roman Sharkov
https://blog.filippo.io/rustgo/ here's an indepth...

I actually meant 'calling Go from Rust' not 'calling Rust from Go'

Anchit
yes, a GUI application can start two different pro...

which has its own problems 1. shipping another executable 2. IPC is platform dependent

Raymond
I actually meant 'calling Go from Rust' not 'calli...

rust can call C functions and go can expose a C ABI

A​kshit
which has its own problems 1. shipping another exe...

youre already shipping two files, a dynamic lib and an executable. why not ship two bins and something to start both (one in the background) insteadf

Raymond- Автор вопроса
A​kshit
rust can call C functions and go can expose a C AB...

I know how Rust can call C functions. I've already did. Thanks for explaination.

Raymond
I know how Rust can call C functions. I've already...

have you worked with cgo? if yes then you know how to expose a go function to C

Raymond- Автор вопроса
A​kshit
have you worked with cgo? if yes then you know how...

I haven't actually used cgo. I barely know Golang.

Raymond
I haven't actually used cgo. I barely know Golang.

hmmm but i guess that answers your question

Raymond
I actually meant 'calling Go from Rust' not 'calli...

https://stackoverflow.com/questions/6125683/call-go-functions-from-c according to my personal experience it's really hacky and you should try to avoid it. what's the reason you want non-Go code to call Go?

Raymond- Автор вопроса
Roman Sharkov
https://stackoverflow.com/questions/6125683/call-g...

I'm currently learning Go and I thought it would be fun to do it since I already did in other programming languages.

A​kshit
its not that hacky

still, whenever cgo is involved I already start doubting the approach 🙂

Raymond
I'm currently learning Go and I thought it would b...

well, if you're learning Go then why even touch cgo in the first place? 😅 https://dave.cheney.net/2016/01/18/cgo-is-not-go

Raymond- Автор вопроса
Roman Sharkov
well, if you're learning Go then why even touch cg...

Why should I avoid it? I always try this when learning a new compiled language and I learn a lot with it.

Raymond- Автор вопроса

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта