diff --git a/kadai1/imura81gt/.devcontainer/Dockerfile b/kadai1/imura81gt/.devcontainer/Dockerfile new file mode 100644 index 0000000..12623de --- /dev/null +++ b/kadai1/imura81gt/.devcontainer/Dockerfile @@ -0,0 +1,68 @@ +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +FROM golang:1 + +# Avoid warnings by switching to noninteractive +ENV DEBIAN_FRONTEND=noninteractive + +# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux, +# this user's GID/UID must match your local user UID/GID to avoid permission issues +# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See +# https://aka.ms/vscode-remote/containers/non-root-user for details. +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Configure apt, install packages and tools +RUN apt-get update \ + && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ + # + # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed + && apt-get -y install git iproute2 procps lsb-release \ + # + # Install gocode-gomod + && go get -x -d github.com/stamblerre/gocode 2>&1 \ + && go build -o gocode-gomod github.com/stamblerre/gocode \ + && mv gocode-gomod $GOPATH/bin/ \ + # + # Install Go tools + && go get -u -v \ + github.com/mdempsky/gocode \ + github.com/uudashr/gopkgs/cmd/gopkgs \ + github.com/ramya-rao-a/go-outline \ + github.com/acroca/go-symbols \ + github.com/godoctor/godoctor \ + golang.org/x/tools/cmd/guru \ + golang.org/x/tools/cmd/gorename \ + github.com/rogpeppe/godef \ + github.com/zmb3/gogetdoc \ + github.com/haya14busa/goplay/cmd/goplay \ + github.com/sqs/goreturns \ + github.com/josharian/impl \ + github.com/davidrjenni/reftools/cmd/fillstruct \ + github.com/fatih/gomodifytags \ + github.com/cweill/gotests/... \ + golang.org/x/tools/cmd/goimports \ + golang.org/x/lint/golint \ + golang.org/x/tools/cmd/gopls \ + github.com/alecthomas/gometalinter \ + honnef.co/go/tools/... \ + github.com/golangci/golangci-lint/cmd/golangci-lint \ + github.com/mgechev/revive \ + github.com/derekparker/delve/cmd/dlv 2>&1 \ + # + # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. + && groupadd --gid $USER_GID $USERNAME \ + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ + # [Optional] Add sudo support + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME \ + # + # Clean up + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/kadai1/imura81gt/.devcontainer/devcontainer.json b/kadai1/imura81gt/.devcontainer/devcontainer.json new file mode 100644 index 0000000..e9e5f3e --- /dev/null +++ b/kadai1/imura81gt/.devcontainer/devcontainer.json @@ -0,0 +1,32 @@ +// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at +// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/go +{ + "name": "Go", + "dockerFile": "Dockerfile", + "runArgs": [ + // Uncomment the next line to use a non-root user. On Linux, this will prevent + // new files getting created as root, but you may need to update the USER_UID + // and USER_GID in .devcontainer/Dockerfile to match your user if not 1000. + // "-u", "vscode", + + "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" + ], + + // Use 'settings' to set *default* container specific settings.json values on container create. + // You can edit these settings after create using File > Preferences > Settings > Remote. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "go.gopath": "/go" + }, + + // Uncomment the next line if you want to publish any ports. + // "appPort": [], + + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "go version", + + // Add the IDs of extensions you want installed when the container is created in the array below. + "extensions": [ + "ms-vscode.go" + ] +} \ No newline at end of file diff --git a/kadai1/imura81gt/README.md b/kadai1/imura81gt/README.md new file mode 100644 index 0000000..cc5e8d0 --- /dev/null +++ b/kadai1/imura81gt/README.md @@ -0,0 +1,183 @@ +Convert Image +================================================================================ + +TOC +-------------------------------------------------------------------------------- +- [Convert Image](#convert-image) + - [TOC](#toc) + - [Q. 【TRY】画像変換コマンドを作ろう](#q-try画像変換コマンドを作ろう) + - [Links](#links) + - [About filepath](#about-filepath) + - [About image](#about-image) + - [Build](#build) + - [Usage](#usage) + - [Test Data](#test-data) + - [Example](#example) + - [e.g. use no option](#eg-use-no-option) + - [e.g. use option](#eg-use-option) + +Q. 【TRY】画像変換コマンドを作ろう +-------------------------------------------------------------------------------- + +次の仕様を満たすコマンドを作って下さい + +- [x] 1. ディレクトリを指定する +- [x] 2. 指定したディレクトリ以下のJPGファイルをPNGに変換(デフォルト) +- [x] 3. ディレクトリ以下は再帰的に処理する +- [x] 4. 変換前と変換後の画像形式を指定できる(オプション) + +以下を満たすように開発してください + +- [x] 5. mainパッケージと分離する +- [x] 6. 自作パッケージと標準パッケージと準標準パッケージのみ使う + - 準標準パッケージ:golang.org/x以下のパッケージ +- [x] 8. ユーザ定義型を作ってみる +- [x] 9. GoDocを生成してみる + + +Links +-------------------------------------------------------------------------------- + +### About filepath + +- https://golang.org/pkg/path/filepath/ + +### About image + +- [Package image](https://golang.org/pkg/image/) + - [gif](https://golang.org/pkg/image/gif/) + - [jpeg](https://golang.org/pkg/image/jpeg/) + - [png](https://golang.org/pkg/image/png/) + - get format + - [DecodeConfig](https://golang.org/pkg/image/#DecodeConfig) +- [The Go Blog](https://blog.golang.org/) + - [The Go image package](https://blog.golang.org/go-image-package#TOC_5.) + + +Go doc +-------------------------------------------------------------------------------- + +``` +$ go doc github.com/gopherdojo/dojo7/kadai1/imura81gt/imgconv/img +package img // import "github.com/gopherdojo/dojo7/kadai1/imura81gt/imgconv/img" + +func AllImageFiles(dirs []string) (files []string) +func Convert(r io.Reader, w io.Writer, t string) error +func ConvertAll(dirs []string, iType ImageType, oType ImageType) error +func ExpectedImageFiles(files []string, iType ImageType) (f []string) +func IsExpectedImage(path string, iType ImageType) bool +func IsImage(path string) bool +type ImageType struct{ ... } +``` + +OR + +``` +cd $(go env GOPATH)/src/github.com/gopherdojo/dojo7/kadai1/imura81gt/imgconv +godoc -http=:8080 +``` + +http://localhost:8080/pkg/github.com/gopherdojo/dojo7/kadai1/imura81gt/imgconv/img/ + +Build +-------------------------------------------------------------------------------- + +``` +cd $(go env GOPATH)/src/github.com/gopherdojo/dojo7/kadai1/imura81gt/imgconv +GO111MODULE=on go build +``` + +Usage +-------------------------------------------------------------------------------- + +``` +$ ./imgconv +./imgconv