This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// X needs anything | |
func X(anything interface{}) { | |
// Nothing comes for free - need to see what I got | |
switch value := anything.(type) { | |
case string: | |
fmt.Printf("I got a string!: %s", value) | |
default: | |
fmt.Print("I got... something!") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cols, err := rows.Cols() | |
// rows.Scan wants '[]interface{}' as an argument, but we want the values | |
// loaded into a '[]string'. So we must copy the references into such a slice | |
// See http://code.google.com/p/go-wiki/wiki/InterfaceSlice for details | |
scanArgs := make([]interface{}, len(cols)) | |
values := make([]string, len(cols)) | |
for i := range values { | |
scanArgs[i] = &values[i] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/gopherjs/gopherjs/js" | |
"github.com/rolaveric/pet" | |
) | |
func main() { | |
js.Global.Set("pet", map[string]interface{}{ | |
"New": pet.New, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
(function() { | |
Error.stackTraceLimit = -1; | |
var go$reservedKeywords = ["abstract", "arguments", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "eval", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield"]; | |
var go$global; | |
if (typeof window !== "undefined") { | |
go$global = window; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lines 8-13 | |
var go$global; | |
if (typeof window !== "undefined") { | |
go$global = window; | |
} else if (typeof GLOBAL !== "undefined") { | |
go$global = GLOBAL; | |
} | |
// Lines 1425-1461 | |
go$packages["github.com/rolaveric/gopherjs/pet"] = (function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// User Type | |
function User(name, id) { | |
this.name = name; | |
this.id = id; | |
this.save = function () { | |
DB.query('UPDATE User SET name = ? WHERE id = ?', this.name, this.id); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Namespace created within an IIFE for private scope | |
var user = (function () { | |
// Variable for holding the injected DB interface | |
var DB; | |
// User Type | |
function User(name, id) {/* ... */} | |
return { | |
// Expose a function for setting the DB interface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package user | |
// Interface for a database result row | |
type DBRow interface { | |
GetInt(colnum int) int | |
GetString(colnum int) string | |
} | |
// Interface for a database result | |
type DBResult interface { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:angular/angular.dart'; | |
main() { | |
ngBootstrap(); | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="sample_container_id"> | |
<p sample-text-id>Click me!</p> | |
</div> |