登录
首页 >  Golang >  Go问答

Github Actions 在本地主机上监听

来源:stackoverflow

时间:2024-04-28 12:21:29 273浏览 收藏

哈喽!今天心血来潮给大家带来了《Github Actions 在本地主机上监听》,想必大家应该对Golang都不陌生吧,那么阅读本文就都不会很困难,以下内容主要涉及到,若是你正在学习Golang,千万别错过这篇文章~希望能帮助到你!

问题内容

我正在尝试为我的 go 项目设置自动测试覆盖率分析,但是我无法让它在 github 操作上运行,因为 go test 命令因以下错误而失败:

run go test -race -coverprofile=coverage.txt -covermode=atomic ./...
go: downloading github.com/alyu/configparser v0.0.0-20191103060215-744e9a66e7bc
go: downloading gorm.io/driver/mysql v1.1.2
go: downloading gorm.io/driver/postgres v1.1.1
go: downloading gorm.io/driver/sqlite v1.1.5
go: downloading gorm.io/gorm v1.21.15
go: downloading gopkg.in/guregu/null.v4 v4.0.0
go: downloading github.com/gorilla/mux v1.8.0
go: downloading github.com/go-sql-driver/mysql v1.6.0
go: downloading github.com/jackc/pgx/v4 v4.13.0
go: downloading github.com/mattn/go-sqlite3 v1.14.8
go: downloading github.com/jinzhu/inflection v1.0.0
go: downloading github.com/jinzhu/now v1.1.2
go: downloading github.com/jackc/pgconn v1.10.0
go: downloading github.com/jackc/pgio v1.0.0
go: downloading github.com/jackc/pgproto3/v2 v2.1.1
go: downloading github.com/jackc/pgtype v1.8.1
go: downloading github.com/jackc/chunkreader/v2 v2.0.1
go: downloading github.com/jackc/pgpassfile v1.0.0
go: downloading github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b
go: downloading golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
go: downloading golang.org/x/text v0.3.7
?       github.com/zaprit/reflow    [no test files]
?       github.com/zaprit/reflow/config [no test files]
?       github.com/zaprit/reflow/database   [no test files]
?       github.com/zaprit/reflow/internal   [no test files]
?       github.com/zaprit/reflow/models [no test files]
2021/10/24 21:59:38 get "http://127.0.0.1:8069/api": dial tcp 127.0.0.1:8069: connect: connection refused
fail    github.com/zaprit/reflow/technicapi 0.049s
?       github.com/zaprit/reflow/utils  [no test files]
fail
error: process completed with exit code 1.

到目前为止,我已经尝试强制测试在 127.0.0.1 上侦听,因为我认为这可能是由于 github 服务器上缺乏 ipv6 支持造成的,尽管这不起作用。

这是我用于测试的 ci 管道

# This lints the Reflow project

name: Lint

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Setup Go environment
        uses: actions/[email protected]
        with:
          go-version: 1.17.1
          stable: true
          token: ${{ github.token }}
      - name: Run golangci-lint
        uses: golangci/[email protected]

正确答案


我修复了它,我猜这是端口的权限问题,因为我切换到使用 net/http/httptest 作为服务器并且它有效。

以上就是本文的全部内容了,是否有顺利帮助你解决问题?若是能给你带来学习上的帮助,请大家多多支持golang学习网!更多关于Golang的相关知识,也可关注golang学习网公众号。

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>