|
Post by bigbass on Apr 19, 2019 17:23:15 GMT 1
objective: the scope of this is not to use golang it is however if you want to mix golang and bacon this is how its done prestep I wasn't sure what I needed at first so I installed these to get started maybe less is needed then started compiling the examples using apt-get golang-17-go golang-go golang-any tutorial gobyexample.com/has the source code to save time github.com/mmcgrana/gobyexampleI wanted to learn golang just for fun its fast and the easiest "new language" I have ever used but if I can't mix it with bacon game over for many things so I figured out how to compile go functions and run them in bacon ! bacon-calls-go.tar.gz (1.16 KB) FIRST TIME DOCUMENTED ! GO AND BACON took me some deep thought how to get it working but its a proof of concept just run the script run-this-only it will do everything you need another language we could use with bacon if needed Tip: I used a premade makefile as a standard we all know but the go way to do it is not to use makefiles at all go build -buildmode=c-archive -o libadder.a from the command line Joe
|
|
|
Post by vovchik on Apr 19, 2019 21:52:33 GMT 1
Dear Joe, Nice work and thanks. Everything compiled fine on Mint (haven't yet tested on RPI3). While I don't know Go, it is good to have it in the arsenal.The ar lib created is huge, however (over 2 MB), and the resulting Bacon binary is 1.2 MB, so we must be loading everything there, including the kitchen sink. In c it would probably be a 3kB binary, so some kind of optimization is really needed. Food for thought. With kind regards, vovchik
|
|
|
Post by bigbass on Apr 20, 2019 2:21:42 GMT 1
Hello vovchik thanks for testing and your comments there are pros and cons development time vs binary size you can also run go lang as a script while testing without compiling a binary this is a big time and space saver just text files no compression needed the main goal I was shooting for is how we could run golang with bacon of course we will find better options and better uses along the way what caught my attention was making a html parser it has already been done in golang this is very interesting what could be done with go gobot.io/need to set a path for downloads setup download directory to install projects export GOPATH=/home/pi/gocode here is a new script to compile and strip the binary and upx it if needed the makefile is not needed anymore #!/bin/sh # simple automatic script by bigbass # keep it simple do the work to build the static file # and keep the steps clear to read cd adder go build -ldflags="-s -w" -buildmode=c-archive -o libadder.a
cp libadder.h libadder.a ../BACON rm -f libadder.*
#compile the bacon file for you cd ../BACON bacon bacon-go.bac
#needed only during compile time #clean up static lib and header after compile rm -f libadder.*
# if heavy compression is needed # sudo apt-get install upx #compress #upx --brute bacon-go #decompress #upx -d bacon-go
xterm -bg WHITE -fg BLACK -hold -e ./bacon-go
|
|
|
Post by vovchik on Apr 20, 2019 12:25:52 GMT 1
Dear Joe, You may have seen this already: go-link. I am trying to digest it. With kind regards, vovchik
|
|
|
Post by bigbass on Apr 20, 2019 15:01:48 GMT 1
hello vovchik thanks for the link it has a lot of good information I saw that after using another link what I was thinking and looking for yes, there are many ways to do something what I didn't want to do was use the old hug.so lib way (like when we started with bacon) and have to place it in the system that it could be found and linked for this reason I didn't try that road that may be the better way in the end but it looked more complex to me and looked for a static way (the way that we now link with C++) to be transparent in the documentation part github.com/draffensperger/go-interlangwas the link I finally settled on using for a static lib porting c code to bacon I thought was the best way it should work and if you go that road that I took when you port to bacon it throws many errors that I finally fixed adding ptheads to get it to compile since there is no (how to bacon for this ) I thought to try to make the road easier for the next guy going down that road Joe
|
|
|
Post by alexfish on Apr 21, 2019 0:14:36 GMT 1
Hi Vovchik I tried the above link go-link and get this BR Alex Sorted : try signing up with mobile phone number = not register :: then click browser <back: Now have the page:: Attachments:
|
|
|
Post by bigbass on Apr 21, 2019 18:16:00 GMT 1
Hello Guys An html parser is always a good tool to have even more now that we have webkit I wont be posting many go examples here but I will post just one so that you can see why I started this thread that we can have other tools at hand and use them in bacon by embedding them shown how in the above posts Really an index2text index2html-src.tar.gz (12.04 KB) Joe
|
|