This file contains hidden or 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 directory is an example package that creates an internal directory for People. | |
This package is an example used for a Blog article and is not for anything else. | |
*/ | |
package directory | |
// Person represents a person and their attributes. |
This file contains hidden or 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
$ shellcheck whoami.sh | |
In whoami.sh line 6: | |
if [ $WHOAMI == "root" ]; then | |
^-----^ SC2086 (info): Double quote to prevent globbing and word splitting. | |
Did you mean: | |
if [ "$WHOAMI" == "root" ]; then | |
For more information: |
This file contains hidden or 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
#! /bin/bash | |
# Simple script that says who I am. | |
WHOAMI=$(whoami) | |
if [ $WHOAMI == "root" ]; then | |
cowsay "I am rooooot!!!" | |
else | |
cowsay "You are $WHOAMI" | |
fi |
This file contains hidden or 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
#! /bin/bash | |
# Simple script that says who I am. | |
WHOAMI=`whoami` | |
if [ $WHOAMI == "root" ] | |
then | |
cowsay "I am rooooot!!!" | |
else | |
cowsay "You are $WHOAMI" |
This file contains hidden or 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
// Set Keepalive time interval | |
err = c.SetKeepAlivePeriod(30 * time.Second) | |
if err != nil { | |
fmt.Printf("Unable to set keepalive interval - %s", err) | |
} |
This file contains hidden or 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
// Open TCP Connection | |
c, err := net.DialTCP("tcp", nil, addr) | |
if err != nil { | |
fmt.Printf("Unable to dial to server - %s", err) | |
} | |
// Enable Keepalives | |
err = c.SetKeepAlive(true) | |
if err != nil { | |
fmt.Printf("Unable to set keepalive - %s", err) |
This file contains hidden or 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
// Resolve TCP Address | |
addr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:9000") | |
if err != nil { | |
fmt.Printf("Unable to resolve IP") | |
} | |
// Start TCP Listener | |
l, err := net.ListenTCP("tcp", addr) | |
if err != nil { | |
fmt.Printf("Unable to start listener - %s", err) |
This file contains hidden or 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
// cfg is used across the app package to contain configuration. | |
var cfg *viper.Viper | |
// Run starts the primary application. It handles starting background services, | |
// populating package globals & structures, and clean up tasks. | |
func Run(c *viper.Viper) error { | |
// Apply config provided by main to the package global | |
cfg = c | |
... |
This file contains hidden or 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 TestRunningServer(t *testing.T) { | |
cfg := viper.New() | |
cfg.Set("disable_logging", true) | |
cfg.Set("listen_addr", "localhost:9000") | |
cfg.Set("kvstore_type", "redis") | |
cfg.Set("redis_server", "redis:6379") | |
cfg.Set("enable_kvstore", true) | |
cfg.Set("debug", true) | |
cfg.Set("trace", true) | |
go func() { |
This file contains hidden or 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 main() { | |
// Initiate a simple logger | |
log := logrus.New() | |
// Setup Config | |
cfg := viper.New() | |
// Set Default Configs | |
cfg.SetDefault("enable_tls", true) | |
cfg.SetDefault("listen_addr", "0.0.0.0:8443") |