Import files from another directory

WBOY
Release: 2024-02-06 08:57:12
forward
577 people have browsed it

Import files from another directory

Question content

I am trying to import utility into github_events.go.

utility.go is placed in the services directory.

utility.go looks like this:

package utility

import (
    "os"
    "regexp"
)
Copy after login

My project structure is as follows:

This is how to import from github_events.go

import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"sync"
"time"
"sort"

"github-app/services/utility"
)
Copy after login

I also tried using the alias utility "github-app/services/utility"

But I get the following error Unable to import github-app/services/utility (No required module provides package "github-app/services/utility") compilerbrokenimport

My go.mod File:

module github-app
    go 1.18
Copy after login

What did i do wrong?


Correct answer


Just import "github-app/services".

The above is the detailed content of Import files from another directory. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!