pope / ob-go Goto Github PK
View Code? Open in Web Editor NEWOrg-Babel support for evaluating go code.
Org-Babel support for evaluating go code.
Can I start working on it? Is there work in progress, or can I start with the latest in git?
My thoughts are between simple (multi-string variable using ` and interpret the s-expression in go) and complex (setup an array of structs with named fields). Any directions for me please!
i prefer to print err message at results section, e.p:
#+BEGIN_SRC go :imports "fmt"
func main() {
fmt.Println("Hello ", name)
}
#+END_SRC
#+RESULTS:
# command-line-arguments
/var/folders/m0/l7hfbwvn3dz9qnx_dxf65vvm0000gp/T/babel-31761XsV/go-src-31761Dez.go:8: undefined: name
It would be convenient if it were possible to also import packages not part of the standard library, e.g., via…
#+begin_src go :imports "golang.org/x/exp/constraints@latest"
…
#+end_src
#+BEGIN_SRC go :imports "fmt"
s := "'h' and 'i'"
fmt.Printf("%s\n", s)
#+END_SRC
#+RESULTS:
: h
When I evaluate a Go snippet looks like above, the output was not properly shown.
With go 1.17 loosing GOPATH support. It may be necessary to generate a temporary module rather than a simple go file when executing the code block.
Using Emacs 26.1 and getting the following error
let*: Symbol’s function definition is void: if-let
althought I add ob-go from melpa, but it doesn't work well. could you tell me how to config it in emacs
Thank you
It will be handy if ob-go
detected import
statements and put them at the beginning of the generated file, without needing to explicitly declare a main()
function, so:
import "fmt"
fmt.Println(1)
will be internally translated to:
package main
import "fmt"
func main() {
fmt.Println(1)
}
Currently this block is translated to invalid go and the compilation fails:
package main
func main() {
import "fmt"
fmt.Println(1)
}
(if-let ((results
(org-babel-eval
(format "%s run %s \"%s\" %s"
org-babel-go-command
(mapconcat 'identity (org-babel-go-as-list flags) " ")
(org-babel-process-file-name tmp-src-file)
(mapconcat #'(lambda (a)
;; If there's a chance that the symbol is a
;; ref, use that. Otherwise, just return the
;; string form of the value.
(format "%S" (if (symbolp a)
(let* ((ref (symbol-name a))
(out (org-babel-read ref)))
(if (equal out ref)
(if (string-match "^\".*\"$" ref)
(read ref)
(org-babel-ref-resolve ref))
out))
a)))
(org-babel-go-as-list args) " ")) "")))
I encountered an "Invalid function" error when I evaluated results, then I find "if-let" in this code block in file "ob-go.el".I guess "if-let" is invalid in my emacs,so I change it into "let",and it works! Finally I find "if-let" is a macro in new Emacs.
when i wrote org like this:
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}
and execute this code, i got:
package main:
/var/folders/m0/l7hfbwvn3dz9qnx_dxf65vvm0000gp/T/babel-31761XsV/go-src-31761BqN.go:2:1: expected 'package', found 'import'
so, i check out generated go source hinted by above, and i found:
import (
)
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}%
is it a bug or my problem?
I am trying to tangle an org file consisting of go code blocks which are all tangled into one file. This package works pretty well besides the inability to set :package to none. For instance, when I untangle I set it so that :main no is a default argument for source blocks but there is no ability to set :package to an empty string or nil leading to the resulting tangled file being filled with various 'package main' lines all over for each source block. Adding this would definitely be useful for overall literate go programming with the package.
I am using Emacs 25 (compiled from source) and org-mode (release-8.3.4)
When I try code block as below:
#+BEGIN_SRC go
fmt.Println("Hello World!")
#+END_SRC
I got error: "Symbol's function definition is void: org-babel--get-vars"
When I install org-mode from master branch, it works fine.
As the title.
I'm using Emacs version from source code repository with branch master
. and Org-mode version from source code branch master
.
And workaround is here:
(if (not (fboundp 'string-to-int)) ; used in `ob-go.el'
(defalias 'string-to-int 'string-to-number))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.