βββ common # common package holding common, utility components.
βββ users # users package holding users-related components.
π¨βπ»
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 | |
# Exit immediately on failure. | |
set -e | |
# Derive local workspace's absolute path from script's path. | |
LOCAL_WORKDIR=$(cd $(dirname $(dirname "${BASH_SOURCE[0]}")) >/dev/null 2>&1 && pwd) | |
main() { | |
# Variables. |
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
Show hidden characters
{ | |
"dockerFile": "Dockerfile", | |
// Configure port mapping between localhost and development container, | |
// should be updated respectively to exposed service ports of referencing container. | |
"appPort": [ | |
"8000:8000" | |
], | |
// Configure to mount local workspace directory to an appropriate workspace directory | |
// within development container. | |
"workspaceMount": "src=${localWorkspaceFolder},dst=/root/project,type=bind", |
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
module github.com/the-evengers/go-restful | |
go 1.13 | |
require github.com/gorilla/mux v1.7.3 |
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
FROM golang:1 | |
# Configure to avoid build warnings and errors as described in official VSCode Remote-Containers extension documentation. | |
# See https://code.visualstudio.com/docs/remote/containers-advanced#_reducing-dockerfile-build-warnings. | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN apt-get update \ | |
&& apt-get -y install --no-install-recommends apt-utils 2>&1 | |
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed. | |
RUN apt-get -y install git iproute2 procps lsb-release |
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 users | |
// User holds a user's data. | |
type User struct { | |
Username string | |
Email string | |
FullName string | |
Bio string | |
} |
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 users | |
import ( | |
"errors" | |
"regexp" | |
) | |
// Regular expressions. | |
var ( | |
regexContainsOnlyDigitsUnderscoreDashesDotsAlpha = regexp.MustCompile(`^[0-9a-zA-Z_\.\-]*$`) |
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 common | |
import "fmt" | |
// Errors is a collection of errors. | |
type Errors []error | |
func (errs Errors) Error() string { | |
msgs := make([]string, len(errs)) | |
for i, err := range errs { |
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 users | |
import ( | |
"errors" | |
"regexp" | |
"github.com/the-evengers/go-restful/common" | |
) | |
// ... other stuff ... |
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 users | |
import ( | |
"github.com/stretchr/testify/assert" | |
"testing" | |
) | |
func TestValidateUser(t *testing.T) { | |
tests := []struct { | |
user User |