万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・資産運用おすすめ
    10万円は1000円くらい利益
    資産運用ブログ アセマネ
    • ・寄付お願いします
      YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
      BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
      c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1
      Skycoin:KMqcn7x8REwwzMHPi9fV9fbNwdofYAWKRo

    gin-scaffoldの使い方

    Go言語WebフレームワークGinのスキャフォルディングがない。

    Gin Scaffold

    https://github.com/dcu/gin-scaffold

    これの使い方

    インストールする。

    go get github.com/dcu/gin-scaffold

    git-scaffold init プロジェクト名 でプロジェクト生成。 僕は~/bin/の下にあるので・・。

    ~/bin/gin-scaffold init scatest

    中身はこうなってた。

    > ls scatest
    config      controllers helpers     models      scatest.go

    起動するのはscatest.goだ。

    go run scatest.go

    そのままでは、パスがフルパスだったので

    import(
     //"/Users/shinriyo/scatest/controllers"
     "scatest/controllers"

    を修正した。 デフォルトでは、4000番ポートでアクセス。 http://localhost:4000/にアクセスする。

    他のフレームワークとかぶったりするので、 変えたい時はscatest.goport = "4001"を変える。

    scaffoldを使う時

    準備

    github.com/Sirupsen/logrus

    これはだめ。Userは大文字開始

    ~/bin/gin-scaffold scaffold user name:int
    controllers/users.go:6:2: cannot find package "models" in any of:
        /usr/local/opt/go/libexec/src/models (from $GOROOT)
        /Users/shinriyo/src/models (from $GOPATH)

    horie1024.hatenablog.com

    さもなくばエラー。

    ~/bin/gin-scaffold scaffold User name:int

    models/user.goがおかしい。

    // User is a model
    type User struct {
         ID bson.ObjectId  `bson:"_id,omitempty"`
         // name int `bson:"name"`
         name string `bson:"name"`
         CreatedAt int64 `bson:"created_at"`
         UpdatedAt int64 `bson:"updated_at"`
         Errors helpers.Errors `bson:"-"`
    }

    intではなくてstringに。

    MongoDBを入れる

    この辺を見て起動しておく

    qiita.com

    アクセス

    http://localhost:4000/users

    {"count":0,"items":[],"success":true}

    Realm

         // This is the main entry point of the application.
            static void Main(string[] args)
            {
                // if you want to use a different Application Delegate class from "AppDelegate"
                // you can specify it here.
                UIApplication.Main(args, null, "AppDelegate");
            }
    No RealmObjects. Has linker stripped them? See https://realm.io/docs/xamarin/latest/#linker-stripped-schema

    このエラー。

    XamarinとVisualStudio for Mac

    Xamarinを起動するとアップデートを促されてた。 そしてアップデートをすると以下の Visual Studio for MacはXamarinの機能以上あるからもうあなたのマシンからXamarin消していいよー。 f:id:shinriyo:20170618155856p:plain

    って・・・。それなら最初からアップデートじゃなくていいのにー。

    すでにPreview版のを入れてたので、それを起動したらこれがでた。 f:id:shinriyo:20170618155801p:plain