Jun 20, 2013

Use multiline strings with Go

 For decelerate the string that contain line breaks, you close back quart.
 If you use the double quart, it arise error.
// string of multiline
var str string
str = `Welcome!
Multi lines message!
Good job!`


You can put the back quart by Shift + @ if you use Mac.



Jun 19, 2013

Go can't looks static files on GAE

 My work was disrupted by the problem that can't read files in static_dir from Go scripts.

 Be careful to below points.
  • Set "static" to files that are readed by web browsers from a user.
  • Must not set "static" to files that are read by go scripts.
 Files in static_dir can not  read  by go scripts. these read by web browsers.

by Google App Engine documents
For efficiency, App Engine stores and serves static files separately from application files. Static files are not available in the application's file system. If you have data files that need to be read by the application code, the data files must be application files, and must not be matched by a static file pattern.

 Therefore, must not put html files to static_dir if you will output a html file dynamically by use of template package.

Jun 18, 2013

Color Go source codes in Xcode 4.x

By default, Xcode does not syntax hightlight.
But, we can configure in the following way.

HOW TO
  1. Download the shell script
  2. Config the path
  3. Execute the shell script
  4. Check

1. Download the shell script

The script that empower Xcode syntax highlighting is distributed.

Download go4xcode.sh  from here.

There is no need to download go.sclangspec, because it is contained in SDK of Google App Engine.
By default, it is here.
/Applications/google_appengine/goroot/misc/xcode/4/go.xclangspec


2. Config the path

The script uses the environment variable $GOROOT.
Check whether it is configured correct path.
$ su
$ echo $GOROOT
If displayed path to goroot, there is no problem.
If else, set the path to goroot.
$ export GOROOT=/Applications/google_appengine/goroot/


3. Execute the shell script

Let's execute the shell script.
$ sh go4xcode.sh
Backing up plugindata file.
Adding Go language specification entry.
Duplicate Entry Was Skipped: Xcode.SourceCodeLanguage.Go
Installing Go language specification file for Xcode.
Run 'sudo rm -rf /var/folders/*' and restart Xcode to update change immediately.
Syntax coloring must be manually selected from the Editor - Syntax Coloring menu in Xcode. 

Remove trashes according to message.
$ rm -rf /var/folders/*

it's complete.


4. Check

Launch the Xcode.
If installing is succeed, there is a new menu Editor -> Syntax Coloring -> Go.



When click this, Xcode syntax highlighting source code.
But this is not configure automatic.