Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: 76069b9fc9
...
compare: b575f5011a
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 36 additions and 0 deletions.
  1. +22 −0 2013/import-c/import-c.slide
  2. +14 −0 2013/import-c/sqrt.go
View
22 2013/import-c/import-c.slide
@@ -0,0 +1,22 @@
+import "C"
+Calling C From Go
+20 Mar 2013
+Tags: go c
+
+Miki Tebeka
+Technical Lead, Adconion
+miki.tebeka@gmail.com
+http://mikitebeka.com
+@tebeka
+
+* Why C?
+
+After all we have Go, which is much better :)
+
+However, there is a *huge* volume of software written in C.
+We'd like to re-use it and not re-write it.
+
+
+* Minimal Example
+
+.play sqrt.go
View
14 2013/import-c/sqrt.go
@@ -0,0 +1,14 @@
+package main
+
+import "fmt"
+
+// #include <math.h>
+// #cgo LDFLAGS: -lm
+import "C"
+
+
+func main() {
+ v := 16.0
+ s := C.sqrt(C.double(v))
+ fmt.Printf("sqrt(%f) = %f\n", v, s)
+}

No commit comments for this range

Something went wrong with that request. Please try again.