Skip to content
This repository has been archived by the owner on Nov 22, 2018. It is now read-only.

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mikespook committed Dec 4, 2014
2 parents 0c9d003 + 8ba5d06 commit f0c5994
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 16 deletions.
2 changes: 1 addition & 1 deletion content/flowcontrol/for-continued.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "fmt"

func main() {
sum := 1
for sum < 1000 {
for ; sum < 1000; {
sum += sum
}
fmt.Println(sum)
Expand Down
2 changes: 1 addition & 1 deletion content/methods/exercise-reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "code.google.com/p/go-tour/reader"

type MyReader struct{}

// TODO: Add a Read(byte) (int, error) method to MyReader.
// TODO: Add a Read([]byte) (int, error) method to MyReader.

func main() {
reader.Validate(MyReader{})
Expand Down
2 changes: 1 addition & 1 deletion content/welcome.article
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ http://golang.org
#appengine:
#appengine: - 在 Playground 中,时间从 2009-11-10 23:00:00 UTC(了解这个日期的重要含义是留给读者的练习)。这使得根据可预见的输出来缓存程序变得容易。
#appengine:
#appengine: - 对于运行时间、CPU 和内存的使用同样也有限制,并且程序是限制单一线程运行(但是可以有多个 goroutine)
#appengine: - 对于运行时间、CPU 和内存的使用同样也有限制,并且程序不能访问外部网络中的主机
#appengine:
#appengine: Playground 使用最后发布的 Go 的稳定版本。
#appengine:
Expand Down
2 changes: 1 addition & 1 deletion gotour/appengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"appengine"

_ "code.google.com/p/go.tools/playground"
_ "golang.org/x/tools/playground"
)

const runUrl = "http://golang.org/compile"
Expand Down
10 changes: 4 additions & 6 deletions gotour/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"strings"
"time"

"code.google.com/p/go.tools/playground/socket"
"golang.org/x/tools/playground/socket"

// Imports so that go build/install automatically installs them.
_ "bitbucket.org/mikespook/go-tour-zh/pic"
_ "bitbucket.org/mikespook/go-tour-zh/tree"
Expand All @@ -41,7 +41,6 @@ var (
)

var (

// GOPATH containing the tour packages
gopath = os.Getenv("GOPATH")

Expand Down Expand Up @@ -77,12 +76,12 @@ func findRoot() (string, error) {
func main() {
flag.Parse()


// find and serve the go tour files
root, err := findRoot()
if err != nil {
log.Fatalf("Couldn't find tour files: %v", err)
}

log.Println("Serving content from", root)

host, port, err := net.SplitHostPort(*httpListen)
Expand Down Expand Up @@ -170,10 +169,9 @@ func init() {
func environ() (env []string) {
for _, v := range os.Environ() {
if !strings.HasPrefix(v, "GOPATH=") {
env = append(env, v)
env = append(env, v)
}
}

env = append(env, "GOPATH="+gopath)
return
}
Expand Down
4 changes: 2 additions & 2 deletions gotour/tour.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"strings"
"time"

"code.google.com/p/go.tools/godoc/static"
"code.google.com/p/go.tools/present"
"golang.org/x/tools/godoc/static"
"golang.org/x/tools/present"
)

var (
Expand Down
7 changes: 7 additions & 0 deletions static/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ ul {
font-family:'Inconsolata', monospace;
line-height: 1.2em;
}
.CodeMirror-code > .line-error {
background: #FF8080;
}
.CodeMirror-code > .line-error .CodeMirror-linenumber {
color: #FF5555;
font-weight: bolder;
}
#file-editor .CodeMirror-gutters {
width: 32px;
}
Expand Down
33 changes: 29 additions & 4 deletions static/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,28 @@ factory('i18n', ['translation',
]).

// Running code
factory('run', ['$window',
function(win) {
factory('run', ['$window', 'editor',
function(win, editor) {
var writeInterceptor = function(writer) {
return function(write) {
if (write.Kind == 'stderr') {
var lines = write.Body.split('\n');
for (var i in lines) {
var match = lines[i].match(/.*\.go:([0-9]+): ([^\n]*)/);
if (match !== null) {
editor.highlight(match[1], match[2]);
}
}
}
writer(write);
};
};
return function(code, output, options) {
// PlaygroundOutput is defined in playground.js which is prepended
// to the generated script.js in gotour/tour.go.
// The next line removes the jshint warning.
// global PlaygroundOutput
win.transport.Run(code, PlaygroundOutput(output), options);
win.transport.Run(code, writeInterceptor(PlaygroundOutput(output)), options);
};
}
]).
Expand Down Expand Up @@ -108,7 +122,17 @@ factory('editor', ['$window', 'storage',
};
set();
},
highlight: function(line, message) {
$('.CodeMirror-code > div:nth-child(' + line + ')')
.addClass('line-error').attr('title', message);
},
onChange: function() {
$('.line-error').removeClass('line-error').attr('title', null);
}
};
// Set in the window so the onChange function in the codemirror config
// can call it.
win.codeChanged = ctx.onChange;
return ctx;
}
]).
Expand Down Expand Up @@ -171,7 +195,8 @@ factory('toc', ['$http', '$q', '$log', 'tableOfContents', 'storage',
}
moduleQ.resolve(modules);
lessonQ.resolve(lessons);
}, function(error) {
},
function(error) {
$log.error('error loading lessons : ', error);
moduleQ.reject(error);
lessonQ.reject(error);
Expand Down
5 changes: 5 additions & 0 deletions static/js/values.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ value('ui.config', {
'PageUp': function() {
return false;
},
},
// TODO: is there a better way to do this?
// AngularJS values can't depend on factories.
onChange: function() {
if (window.codeChanged !== null) window.codeChanged();
}
}
});

0 comments on commit f0c5994

Please sign in to comment.