Skip to content

Instantly share code, notes, and snippets.

View steevehook's full-sized avatar
📖
redefining education

Steve Hook steevehook

📖
redefining education
View GitHub Profile
func (s *someSuite) newServer(handler http.Handler) (*httptest.Server, func()) {
done := make(chan struct{})
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
s.NotPanics(func() { handler.ServeHTTP(w, r) })
close(done)
}))
closeFunc := func() {
server.Close()
<-done
}
@steevehook
steevehook / gitBash_windows.md
Created December 29, 2019 20:50 — forked from evanwill/gitBash_windows.md
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows comes bundled with the "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root. Find it by using pwd -W). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on).

If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corresponding directories. Sometimes the windows binary have funny prefixes, so

func findJSONEnd(file *os.File, end byte) int64 {
fileInfo, err := file.Stat()
if err != nil {
log.Fatalf("could not read file stat: %v", err)
}
size := fileInfo.Size()
var ret int64
for i := 1; i <= int(size); i++ {
bs := make([]byte, 1)
r, err := file.Seek(-int64(i), io.SeekEnd)
package main
import (
"bufio"
"fmt"
"os"
"path/filepath"
"strings"
)
module github.com/gophertuts/go-basics/packages/go-get
go 1.12
require github.com/julienschmidt/httprouter v1.3.0
package main
import (
"fmt"
"github.com/gophertuts/go-basics/constants/scope/p1"
)
const (
Exported = 10
unExported = "Hello"
package main
import "github.com/gophertuts/go-basics/packages/package-types/services"
func main() {
services.NewS1()
}
#!/bin/bash
coverage_dir=".cover"
coverage_file="cover.out"
coverage_output="${coverage_dir}/${coverage_file}"
coverage_mode="count"
integration_build_tag="intgr"
help_message="coverage.sh
\t--html Additionally creates HTML report and open it in browser\n
\t\t--${integration_build_tag} Runs all tests including the ones with ${integration_build_tag} tag\n
function setEl(el, amount) {
if (el) {
el.innerHTML = `$${amount}.00`
}
}
function setElCust(el, amount) {
if (el) {
el.innerHTML = `${amount}`
}
// WithTimeout runs a function and fails if it didn't finish within the timeout
func (s *Suite) WithTimeout(timeout time.Duration, fn func()) {
ch := make(chan struct{})
go func() {
fn()
ch <- struct{}{}
}()
select {
case <-time.After(timeout):