Skip to content

Instantly share code, notes, and snippets.

Golang 101

事前準備

Go言語での開発をするために、まずは環境整備をしましょう。

Go言語のインストール

公式サイトより、ご自身の環境に合わせてインストーラをダウンロードし、Go言語の実行環境をインストールしてください。 バージョンは最新(本ガイドを書いた時点では1.12.6)をインストールしてください。

@tikidunpon
tikidunpon / golang.md
Last active February 13, 2018 13:42
go(golang)勉強会 #1

最近のシステム開発の傾向

  • コンピュータは速くなったが、ソフトウェア開発は速くなっていない
  • 依存性の管理はソフトウェア開発の多くを占める、しかしC言語のヘッダーでは高速に依存性を分析しづらい
  • JavaやC++のような扱いにくい型システムをもつシステムより、PythonやJavaScriptなど動的片付け言語が使われている
  • ガーベジコレクションや並列計算などの基本的なコンセプトのいくつかは一般的な言語で上手くサポートされていません
  • マルチコアコンピュータの登場により、心配と混乱が生じた

上記を受けてGoが解決を目指すこと

package main
import "fmt"
// WithPrefix
type prefixOption struct{}
func WithPrefix() interface {
GetOption
@ezura
ezura / accessControl1.kt
Last active July 18, 2017 05:39
kotlin 可視性実験
class A {
private fun f() = print("private")
fun _f() = f() // use `private fun f()`
}
fun A.f() = print("extension")
fun A._f() = print("extension _f") // ignored 😖
/*
val a = A()
@tomaszpolanski
tomaszpolanski / Variance.kt
Created July 3, 2017 16:07
Covariance vs Contravariance
package com.tomek
abstract class Animal(val size: Int)
class Dog(val cuteness: Int): Animal(100)
class Spider(val terrorFactor: Int): Animal(1)
// Covariance
@es-kumagai
es-kumagai / CodePiece.swift
Created May 24, 2017 11:04
ちなみに catch {} で暗黙宣言される error 変数の名前を変えたい時はこんな感じ。 #read_swift #CodePiece
struct SomeError : Error {
}
let error = SomeError()
error._code // 1
error._domain // __lldb_expr_16.SomeError
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
var i int
var n [3]int
return func() int {
@eyasuyuki
eyasuyuki / WASBOOK.md
Last active May 29, 2022 00:58
「体系的に学ぶ 安全なWebアプリケーションの作り方」の仮想環境をVagrantで動かす

前提条件

2015-10-28 現在

  • OS X 10.11.1
  • VirtualBox
  • Vagrant

仮想マシンイメージの入手またはダウンンロード

スイッチとLEDを連動

import mraa
import time

class Counter(object):
    count = 0

c = Counter()

AWS API-Gateway と LCD を組み合わせて利用する

import time
import requests
import pyupm_i2clcd as lcd

# requests モジュールでAPIからGET
r = requests.get('https://d6h35jv1q8.execute-api.us-east-1.amazonaws.com/production/weather').json()