为什么我的GitHub操作脚本找不到我的内部go包?

为什么我的GitHub操作脚本找不到我的内部go包?,go,action,github-actions,Go,Action,Github Actions,我正在学习Go并希望使用GitHub操作。当只使用一个包时,一切都很好。但是,一旦我定义了多个包(比主包多),我就会被绊倒。在我的桌面上,它确实可以编译,但通过使用操作脚本,它不会编译,并最终导致以下错误: Run go build -v main.go main.go:4:2: cannot find package "Landsat-Extractor/logger" in any of: /opt/hostedtoolcache/go/1.14.4/x64/src/Landsat-

我正在学习Go并希望使用GitHub操作。当只使用一个包时,一切都很好。但是,一旦我定义了多个包(比主包多),我就会被绊倒。在我的桌面上,它确实可以编译,但通过使用操作脚本,它不会编译,并最终导致以下错误:

Run go build -v main.go
main.go:4:2: cannot find package "Landsat-Extractor/logger" in any of:
    /opt/hostedtoolcache/go/1.14.4/x64/src/Landsat-Extractor/logger (from $GOROOT)
    /home/runner/go/src/Landsat-Extractor/logger (from $GOPATH)
##[error]Process completed with exit code 1.
文件结构为:

go
└───src
    └───Landsat-Extractor
        │   main.go
        │
        └───logger
        |   │   logger.go
        |
        └───.github
            └───workflows
                |   go.yml
在我的本地机器上,GOPATH设置为上一个文件结构的
go

我的动作脚本go.yml是:

name: Go

on:
  push:
    branches: [ master, feature_githubaction ]

jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:

    - name: Set up Go 1.x
      uses: actions/setup-go@v2
      with:
        go-version: ^1.14
      id: go

    - name: Check out code into the Go module directory
      uses: actions/checkout@v2

    - name: Build
      run: go build -v main.go

主要目标是:

package main

import (
    "Landsat-Extractor/logger"
)

func main() {

    logger.Create()
    defer logger.Destroy()

    logger.Info("A message")

}

logger.go是:

package logger

// Create inits the Logger
func Create() {
    println("Creating")
}

// Info logs a message
func Info(msg string) {
    println(msg)
}

// Destroy closes writers
func Destroy() {
    println("Closing")
}


~/go/src/Landsat提取器中运行
go mod init

这将有助于解决模块导入问题