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
//main.qml | |
... | |
import { | |
... | |
} | |
var ctx qml.Context //Global var to set the qml context | |
... |
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
//assets/main.qml | |
... | |
TextArea { | |
id: mdarea | |
... | |
text: mdtxt //A variable name to reference from the Golang code | |
} | |
TextArea { | |
id: rtarea |
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
//assets/main.qml | |
import QtQuick 2.3 //Needed to import all base QML entities | |
import QtQuick.Controls 1.4 //Needed for ApplicationWindow and TextArea | |
import QtQuick.Layouts 1.0 //For the RowLayout | |
ApplicationWindow { //The base entity so we can set a toolbar later and the layout | |
width: 640 //Default width | |
height: 480 //Default height | |
color: "#f1f1f1" //Background Color |
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
//main.go | |
... | |
func run() error { | |
engine := qml.NewEngine() //Create the QML engine | |
engine.On("quit", func() { os.Exit(0) }) //If quit is called from QML the Golang program will gracefully quit | |
component, err := engine.LoadFile("assets/main.qml") //Load the QML file | |
if err != nil { |
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
// main.go | |
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/atotto/clipboard" | |
"github.com/russross/blackfriday" |
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
//main.go | |
... | |
func main() { | |
... | |
for ... {...} | |
// Here we allocate and create a buffer that can easily be | |
// turned into a []byte |
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
//main.go | |
package main | |
import (...) | |
func main() { | |
// Seed the std random number generator | |
rand.Seed(time.Now().UTC().UnixNano()) | |
// We will leave out creating the png image file since we |
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
//main.go | |
package main | |
import ( | |
"fmt" | |
"image" | |
"image/color" | |
"image/draw" | |
"image/png" | |
"math/rand" |
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
// ./main.go | |
package main | |
import "os" | |
// When we run `go generate` from the cli it will run the | |
// `go run` command outlined below | |
// **Important: sure to include the comment below for the generator to see** | |
//go:generate go run generators/generator.go |
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
// ./generators/generator.go | |
package main | |
//Much of this file is from http://stackoverflow.com/questions/17796043/golang-embedding-text-file-into-compiled-executable | |
import ( | |
"fmt" | |
"io/ioutil" |