Skip to content

jccampagne/gojulia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Simple examples showing how to embed Julia in Go.

Requirements

Julia, Go, Make.

go, julia and julia-config.jl in your path.

You will probably have to add julia-config.jl to your PATH. Julia config tool on macOS, using Julia installed with brew is located here:

/Applications/Julia-1.2.app/Contents/Resources/julia/share/julia/julia-config.jl

Run the examples

This was tested on macOS, but should also work on Linux.

A makefile is provide for convenience, just type:

make

This will compile the examples and run them (note: one of the example will fail on purpose).

Description

There are 3 examples:

  1. gjl.go: very simple example
  2. gjl_goroutines.go: executing julia code from 2 different goroutines with synchronisation.
  3. gjl_goroutines_fail.go: same as above example, but demonstrate failure when accessing julia from multiple goroutine without synchronization.

C binding

Julia is embedding in Go using cgo and a couple of C binding files: gjl.h and gjl.c. These files provide function wrappers around Julia C API that are defined C macros in Julia. Cgo cannot use C macros directly. For example jl_typeof(v) is a macro.

References