Use Dart to call Shell, complete the work of compiling Golang CGO code into a so, dll, a, WASM, and etc.

Overview

BindGo

😭
😭 😭
Use Dart to call Shell, complete the work of compiling Golang CGO code into a so, dll, a, WASM, and etc. And place it in the corresponding source file directory of each Flutter platform.


Getting started

First, add bindgo as a dev dependency in your pubspec.yaml file. It belongs in dev_dependencies because it is a command line tool.

dev_dependencies:
  bindgo: any

Usage

  1. Adding your config to field bindgo in pubspec.yaml

e.g. :

bindgo:
  name: test # Dynamic library output name
  main: ./test # The directory where the main package of golang code is located
  platforms:
    windows:
      arch:
        - 'amd64'
    android:
      arch:
        - 'arm64'
      cc: '${NDK}/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android27-clang.cmd'
  1. Run the following command in the terminal
dart run bindgo

or

flutter pub run bindgo:run

Additional information

View the operating systems and architectures supported by the current version of golang:

go tool dist list

e.g. :

# golang v1.17.2

...
android/386
android/amd64
android/arm
android/arm64
---
darwin/amd64
darwin/arm64
...
ios/amd64
ios/arm64
---
js/wasm
---
linux/386
linux/amd64
linux/arm
linux/arm64
...
windows/386
windows/amd64
windows/arm
windows/arm64
You might also like...

Just a jellyfin client made in flutter (side project quality code)

Just a jellyfin client made in flutter (side project quality code)

jellyflut A jellyfin client made in Flutter It's a beta, it works okay. You can : Play a video Read a book Listen Music Look photos SQLite to have log

Jan 4, 2023

Flutter date range pickers use a dialog window to select a range of date on mobile.

Flutter date range pickers use a dialog window to select a range of date on mobile.

[Deprecated] Date Range Picker Currently Flutter has supported date range picker, so I think my mission is done. Thanks for using my lib. Link: https:

Dec 28, 2022

Dart web - Experimental web framework for Dart. Supports SPA and SSR

dart_web Experimental web framework for Dart. Supports SPA and SSR. Relies on pa

Dec 23, 2022

Pure Dart Argon2 algorithm (the winner of the Password Hash Competition 2015) for all Dart platforms (JS/Web, Flutter, VM/Native).

argon2 Pure Dart Argon2 algorithm (the winner of the Password Hash Competition 2015) for all Dart platforms (JS/Web, Flutter, VM/Native). Based on the

Dec 22, 2021

Serverpod is a next-generation app and web server, explicitly built for the Flutter and Dart ecosystem.

Serverpod is a next-generation app and web server, explicitly built for the Flutter and Dart ecosystem.

Serverpod Serverpod is a next-generation app and web server, explicitly built for the Flutter and Dart ecosystem. It allows you to write your server-s

Jan 8, 2023

Biyi (比译) is a convenient translation and dictionary app written in dart / Flutter.

Biyi (比译) is a convenient translation and dictionary app written in dart / Flutter.

biyi_app Biyi is a convenient translation and dictionary app written in dart / Flutter. View document "Biyi" (比译) is the Chinese word for "Comparison

Jan 1, 2023

Experimental web framework for Dart. Supports SPAs and SSR.

jaspr Experimental web framework for Dart. Supports SPAs and SSR. Main Features: Familiar component model similar to Flutter widgets Easy Server Side

Jan 4, 2023

Native Dart client library for DBus

A native Dart client implementation of D-Bus. Accessing a remote object using dart-dbus The easiest way to get started is to use dart-dbus to generate

Oct 28, 2022

A Dart FFI package to send 💬 toasts on Windows. Written in C++, based on WinToast.

A Dart FFI package to send 💬 toasts on Windows. Written in C++, based on WinToast.

desktoasts A Dart package to send native 💬 toasts on Windows. Installation For Flutter dependencies: ... desktoasts: ^0.0.2 For Dart CLI here Sup

Mar 7, 2022
Comments
  • Invalid argument(s): Failed to load dynamic library

    Invalid argument(s): Failed to load dynamic library

    请问怎么加载编译好的.so给Andriod使用呢?

    • build.gradle android/app/build.gradle 添加以下内容
        buildTypes {
            release {
                // TODO: Add your own signing config for the release build.
                // Signing with the debug keys for now, so `flutter run --release` works.
                signingConfig signingConfigs.debug
                // 调用.so
                ndk {
                    abiFilters "arm64-v8a"
                }
            }
            //
            debug {
                signingConfig signingConfigs.debug
                ndk {
                    abiFilters "armeabi","armeabi-v7a","arm64-v8a", "x86"
                }
            }
        }
    

    flutter run -d ASUS\ Z012DE

    The following ArgumentError was thrown building MyApp(dirty):
    Invalid argument(s): Failed to load dynamic library
    './android/app/src/main/jniLibs/arm-v8a/libgets.so': dlopen failed: library
    "./android/app/src/main/jniLibs/arm-v8a/libgets.so" not found
    
    • 项目根目录查找 find . -name "libget*"
    ./linux/libgets.so
    ./linux/libgets.h
    ./linux/libgets.dll
    ./android/app/src/main/jniLibs/arm-v8a/libgets.so
    ./android/app/src/main/jniLibs/arm-v8a/libgets.h
    ./build/linux/x64/debug/bundle/libgets.dll
    ./build/app/intermediates/stripped_native_libs/debug/out/lib/arm-v8a/libgets.so
    ./build/app/intermediates/merged_native_libs/debug/out/lib/arm-v8a/libgets.so
    ./build/app/intermediates/merged_jni_libs/debug/out/arm-v8a/libgets.so
    ./build/app/intermediates/merged_jni_libs/debug/out/arm-v8a/libgets.h
    
    opened by Aquarian-Age 0
  • run build c lib, but get the exit code 255, and nothing generate

    run build c lib, but get the exit code 255, and nothing generate

    PS D:\hlp\src\myflutter\gommq> flutter pub run bindgo:run BindGo: windows amd64 starting... Unhandled exception: ShellException(go build -buildmode=c-shared -ldflags "-s -w" -o D:\hlp\src\myflutter\gommq\windows\libgolbi.dll ./golib, exitCode 1, workingDirectory: D:\hlp\src\myflutter\gommq) Instance of '_StringStackTrace'pub finished with exit code 255 PS D:\hlp\src\myflutter\gommq>

    opened by heliping 0
Owner
Dorain Gray
So am i.
Dorain Gray
A Flutter package that makes it easy to customize and work with your Flutter desktop app window.

bitsdojo_window A Flutter package that makes it easy to customize and work with your Flutter desktop app window on Windows, macOS and Linux. Watch the

Bits Dojo 607 Jan 4, 2023
A Flutter package that makes it easy to customize and work with your Flutter desktop app's system tray.

system_tray A Flutter package that that enables support for system tray menu for desktop flutter apps. on Windows, macOS and Linux. Features: - Modify

AnTler 140 Dec 30, 2022
This plugin allows Flutter desktop apps to Retrieve information about screen size, displays, cursor position, etc.

screen_retriever This plugin allows Flutter desktop apps to Retrieve information about screen size, displays, cursor position, etc. screen_retriever P

LeanFlutter 27 Dec 6, 2022
🎵 Elegant music app to play local music & YouTube music. Distributes music into albums & artists. Has playlists & lyrics.

Harmonoid Elegant music app to play local music & YouTube music. Download Now ?? Windows, Linux & Android. Feel free to report bugs & issues. Loving t

Harmonoid 2.5k Jan 8, 2023
JavaScriptCore for Flutter use dart:ffi.

flutter_jscore JavaScriptCore for Flutter. The plugin provides the ability to evaluate JavaScript programs from within dart. Demo Screen recording Apk

KnoYo 131 Jan 3, 2023
A project that makes use of a Typescript back end and a Flutter web front end to consume the Jira API in order to visualize and interact with issues.

A project that makes use of a Typescript back end and a Flutter web front end to consume the Jira API in order to visualize and interact with issues.

Lucas Coelho 1 Mar 20, 2022
Windows95 UI components for Flutter apps. Bring back the nostalgic look and feel of old operating systems with this set of UI components ready to use.

Flutter95 Windows95 UI components for Flutter apps. UNDER CONSTRUCTION Screenshots Components Scaffold95 Scaffold as a Windows95 styled window. Provid

Miguel Beltran 141 Dec 26, 2022
A Javascript engine to use with flutter. It uses quickjs on Android and JavascriptCore on IOS

Flutter JS plugin A Javascript engine to use with flutter. Now it is using QuickJS on Android through Dart ffi and JavascriptCore on IOS also through

Ábner Oliveira 334 Jan 3, 2023
A simple-to-use flutter update package for Windows, MacOS, and Linux.

Updat - The simple-to-use, flutter-based desktop update package Updat is a simple-to-use reliable flutter-native updater that handles your application

Eduardo M. 14 Dec 21, 2022
The no code editor with the full power of @flutter🌸

flutter_blossom ?? Low code editor with the full power of flutter. Think in flutter, watch your ideas come to life, plan ahead and let your creativity

Flutter Blossom 0 Dec 2, 2021