3. But First of All, Me
!
•
Ekin Eylem Ozekin!
•
BSc. In Computer Science, MSc. In Software
Engineering!
•
Currently, Ph.D. Candidate at Bogazici
University, on Machine Learning!
•
Works at GE
!
4. Introduction to Go
!
•
Built around 2007, announced at 2009!
•
By “GO”ogle!
•
Open Source!
•
Similar to C!
•
Statically typed, compiled!
•
No pointer arithmetic
!
5. Introduction to Go
!
•
Automatic memory management, classes
(structs), type inference!
•
First class functions, suitable to functional
programming!
•
Concurrency support, channels
!
6. Introduction to Go
!
•
Ideal for fast, distributed systems!
•
Can import libraries directly from URLs!
•
Built-in UTF-8 support (İ, Ğ etc. works perfectly)!
•
Integrated AppEngine libraries
!
7. Introduction to Go
!
package main!
!
import (!
"fmt"!
"net/http"!
)!
!
func get_name() (string, string) {!
// No reason to break a few rules, right!
var hello = "Hello "!
audience := "DevFestTR"!
return hello, audience!
}!
!
func handler(writer http.ResponseWriter, request *http.Request) {!
hello, audience := get_name()!
fmt.Fprintf(writer, hello + audience)!
}!
!
func main() {!
http.HandleFunc("/", handler)!
http.ListenAndServe(":8080", nil)!
}
!
8. Introduction to Go
!
•
Written as read, left from right!
•
No semicolons!
•
Multiple return values (think of tuples in Python)!
•
Single binary file after compile!
•
More on the previous code later
!
9. Web with Go
!
•
Built-in http package!
•
Similar to J2EE Servlets!
•
But more like a Micro-framework
!
10. Web with Go
!
•
Web Development with the performance of C!
•
Might be deployed with built-in server (port
listener actually)!
•
Deploy to Apache or Nginx with FastCGI!
•
Also mod_go for Apache!
•
Deploy to AppEngine or Heroku
!
12. Is Go Suitable for Web
!
Pros!
•
•
Micro-framework style http package!
•
CGI support (kinda old but solid and useful)!
•
Compiled, fast performance!
•
C like Syntax but better!
•
API is mature enough!
13. Is Go Suitable for Web
!
Cons!
•
•
Not easier then PHP (or Ruby or Python)!
•
Not as widely used as others!
•
Not proven enough yet (can be argued)!
14. Is Go Suitable for Web
!
Last Word!
•
•
Service Oriented Architecture and Micro Frameworks fit well!
•
You don’t have to use just Go, use with others!
•
Google already uses it (isn’t it enough reason?)!
19. Q&A Session
!
•
•
•
•
•
•
•
•
Is there a Database Abstraction layer?!
As there are no classes ORM is a bit crippled. However, there are few implementations on that.
You can find those here: http://jmoiron.net/blog/golang-orms/ . There are also bindings for popular
databases: http://go-lang.cat-v.org/library-bindings!
What can I use for User Interfaces?!
There is a GTK binding for that. For more libraries you can check:
http://go-lang.cat-v.org/library-bindings!
To return multiple values Python returns actually a Tuple data structure. Is it similar in Go too?!
No. Go really returns multiple values.!
If I can something on a template, should I recompile in order to see changes?!
No, you don’t. If you make a change on the template code, all you have to do is refresh the page.
However you should be careful, when deploying to the server you should make sure that those
templates exist too.
!