Go Module - Semantic Issue

Please suggest what wrong in the below module code , as i run the “go run” its printing “v0.0.0-20200905093608-fa27acc19ecf” in the go.mod though i have a TAG associated with it in the github repo(github.com/viveknangal/aws-utils/package4).

kindly help as i m a newbie & have spend last 6 hours to figure out but couldnt find the issue

    ////////// main.go  //// file

    package main

    import (
            "fmt"

            "github.com/viveknangal/aws-utils/package4"
    )

    func main() {
            fmt.Println("This is a Package1")
            fmt.Println(package4.GetName())
    }

/////// go run command //////////
go run main.go 
go: finding module for package github.com/viveknangal/aws-utils/package4
go: downloading github.com/viveknangal/aws-utils v1.0.2
go: downloading github.com/viveknangal/aws-utils/package4 v0.0.0-20200905093608-fa27acc19ecf
go: downloading github.com/viveknangal/aws-utils v11.0.0+incompatible
go: found github.com/viveknangal/aws-utils/package4 in github.com/viveknangal/aws-utils/package4 v0.0.0-20200905093608-fa27acc19ecf

    ////////// go.mod  //// file
   module github.com/viveknangal/awsjack

go 1.15

require github.com/viveknangal/aws-utils/package4 v0.0.0-20200905093608-fa27acc19ecf

To use v1.3.0 of github.com/viveknangal/aws-utils try something like this:

go.mod

module github.com/viveknangal/awsjack

go 1.15

require github.com/viveknangal/aws-utils v1.3.0

main.go:

package main

import (
	"fmt"

	package4 "github.com/viveknangal/aws-utils"
)

func main() {
	fmt.Println("This is a Package1")
	fmt.Println(package4.GetName())
}

Calling go get prints this:

$ go get
go: downloading github.com/viveknangal/aws-utils v1.3.0
# github.com/viveknangal/aws-utils
/Users/lutz/go/pkg/mod/github.com/viveknangal/aws-utils@v1.3.0/aws-utils.go:1:12: syntax error: unexpected -, expecting semicolon or newline

The module has an error biut if I understand you correctly, this is what you want: use v1.3.0 of github.com/viveknangal/aws-utils.

Thank you for responding ,but why explicit mention of version v1.0.2 is required ,as per Go DOc version less than < v2 need not required explicit mention of version, Please help in understand that

I m still facing the same issue where the tag isnot getting updated in the go.mod
v0.0.0-20200905093608-fa27acc19ecf
Please suggest ,what i m missing here

"go get " command always downloads pseudo version ,please suggest why it is not downloading the latest Tag 1.0.0 , which is present on this repo . Really struggling …someone pls help:-

go get github.com/viveknangal/module
go: downloading github.com/viveknangal/module v0.0.0-20200905133558-25b756fd6ebd

I still don’t understand what you want to do. Why do you put modules ( package3, pacakge4) into github.com/viveknangal/aws-utils? The later module has tags which could be used if you want to import it. But a module containing “submodules”?

BTWT, don’t name the package aws-utils. The dash - is not legal here.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.