Skip to content

Instantly share code, notes, and snippets.

View campoy's full-sized avatar

Francesc Campoy campoy

View GitHub Profile
@campoy
campoy / home.tmpl
Last active May 4, 2022 19:19
Electron-like html+golang app
<html>
<head>
<title>Hello, from Go</title>
</head>
<body>
<h1>Hello</h1>
<p>
This is Go code running, {{.}}
</p>
</body>
@campoy
campoy / app.go
Created November 18, 2016 23:43
Go Echo server on App Engine Flex
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Sample endpoints demonstrates a Cloud Endpoints API.
package main
import (
"encoding/json"
"fmt"
@campoy
campoy / app.go
Created November 18, 2016 23:48
Go Echo Server on Flex with Endpoints
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Sample endpoints demonstrates a Cloud Endpoints API.
package main
import (
"encoding/json"
"fmt"
@campoy
campoy / pi-fast.go
Last active March 13, 2017 18:10
Computing pi one gcd at a time! Inspired by https://www.youtube.com/watch?v=RZBhSi_PwHU&t=891s
package main
import (
"fmt"
"math"
"math/rand"
"runtime"
"sync"
"time"
)
@campoy
campoy / empty.sh
Created June 27, 2017 23:07
Find all the packages in the standard library that do not expose any symbol
for pkg in $(go list std | grep -v vendor)
do
go build $pkg && if [[ "$(go doc $pkg | grep '^func\|^var\|^type\|^const' | wc -l)" -eq "0" ]]
then
echo $pkg
fi
done
@campoy
campoy / benchmarks_test.go
Created July 10, 2017 22:33
go test -gcflags "-S" generates double definition
package profiling
import "testing"
func div(a, b int) int {
return int(float64(a) / float64(b))
}
var s int
@campoy
campoy / settings.json
Created July 24, 2017 21:11
My vscode settings
{
"window.zoomLevel": 0,
"go.lintOnSave": "package",
"editor.fontFamily": "'Fira Code', Menlo, Monaco, 'Courier New', monospace",
"editor.fontLigatures": false,
"workbench.iconTheme": "vs-seti",
"go.addTags": {
"tags": "json",
"options": "json=omitempty",
"promptForTags": true,
@campoy
campoy / qr.go
Created October 5, 2017 00:48
A simple program to print QR Codes on your terminal
// Copyright 2017 Google Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to writing, software distributed
// under the License is distributed on a "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied.
//
package main
import "fmt"
func main() {
fmt.Println("Hello, world")
}
package main
import (
"fmt"
"os"
)
func main() {
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "usage:\n\t%s [files]\n", os.Args[0])