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 gocontext | |
import ( | |
"context" | |
"log/slog" | |
"sync" | |
"testing" | |
"time" | |
) |
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 http2_test | |
import ( | |
"crypto/tls" | |
"crypto/x509" | |
"net/http" | |
"net/http/httptest" | |
"testing" | |
"time" |
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 resty_test | |
import ( | |
"context" | |
"crypto/tls" | |
"encoding/json" | |
"fmt" | |
"io" | |
"net/http" | |
"net/http/httptest" |
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
func GetExampleData() []byte { | |
return []byte(`"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."`) | |
} | |
var ErrWordTooLong = errors.New("word too long") | |
var ErrBufferEmpty = errors.New("buffer empty") | |
var ErrEndOfWord = errors.New("end of word") | |
func TestWordBuffer(t *testing.T) { | |
b := bytes.NewBuffer(GetExampleData()) |
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
type APIClient struct { | |
baseUrl url.URL | |
} | |
type Something struct { | |
Id string // the response data | |
} | |
// NewAPIClient is a constructor and instantiating our api |
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
// this is a simple example of a semaphore in go. | |
// | |
// it replaces the typical waitgroup pattern. The benefit of a semaphore is that | |
// no workers will be left abandoned and no unneeded workers are started in | |
// contrast to a typical waitgroup based worker pool pattern. We also can only | |
// start a limited amount of workers at once. In a waitgroup we coul start more | |
// workers than we have tasks, which is not always optimal. | |
package main |
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 buffer_test | |
import ( | |
"bytes" | |
"log" | |
"sync" | |
"testing" | |
"time" | |
) |
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
# Description: Sets up a windows developer machine with all needed application to start Microsoft developing right away | |
# | |
# Edited for private and company use by: | |
# Editor 1: Dominik Steffen <[email protected]> | |
# Last Updated: 2017-09-30 | |
# | |
# Original Author: Jess Frazelle <[email protected]>, special thanks to Jess! | |
# | |
# Install boxstarter: | |
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force |
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 sys | |
import math | |
# Test primality for 2 to sqrt(n) and check for rest | |
def testPrimality(n): | |
if(n == 1): | |
return; | |
m = 2 | |
while m < math.sqrt(n): | |
if(n == 1): |
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
# Description: Sets up a windows developer machine with all needed application to start Microsoft developing right away | |
# | |
# Edited for private and company use by: | |
# Editor 1: Dominik Steffen <[email protected]> | |
# Last Updated: 2017-09-30 | |
# | |
# Original Author: Jess Frazelle <[email protected]>, special thanks to Jess! | |
# | |
# Install boxstarter: | |
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force |
NewerOlder