0
0

More than 3 years have passed since last update.

go.modの補足 パッケージ

Last updated at Posted at 2021-01-19

前回の続きです。

[go.mod]
module example.com

go 1.15

require github.com/labstack/echo/v4 v4.1.17

上記のgo.modの一番上の
module example.com
の部分ですが、ここがimportして自分のパッケージを使う時の名前になります!
以下のような構成のプロジェクトの場合↓

test
 |--samplea--aaaaa.go
 |--sampleb--bbbbb.go
 |--main.go
 |--go.mod
 |--go.sum

[main.go]

package main

import(
"example.com/samplea"
"example.com/sampleb"
)

このようにして使います。
ディレクトリの名前とモジュールの名前を同じにしたければ

[go.mod]
module test

にします。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0