Jump to content

V Lang - http module not found??

KaiLikesProgramming
Go to solution Solved by Shubhendra,

instead of using "import http" use "import net.http"

module main
import time
import net.http

fn main() {
	resp := http.get('https://vlang.io/utc_now') or {
		println('failed to fetch data from the server')
		return
	}
	t := time.unix(resp.text.int())
	println(t.format()) // yyyy-mm-dd hh:mm
}

 

So I am working with V Lang and I ran into an issue with trying to use the http module, after trying to test everything with their premade tools I saw this happen:

`cannot import module "http" (not found)`

 

Anyone know what is going on? Any fixes I should know about?

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...

instead of using "import http" use "import net.http"

module main
import time
import net.http

fn main() {
	resp := http.get('https://vlang.io/utc_now') or {
		println('failed to fetch data from the server')
		return
	}
	t := time.unix(resp.text.int())
	println(t.format()) // yyyy-mm-dd hh:mm
}

 

Link to comment
Share on other sites

Link to post
Share on other sites

5 hours ago, Shubhendra said:

instead of using "import http" use "import net.http"


module main
import time
import net.http

fn main() {
	resp := http.get('https://vlang.io/utc_now') or {
		println('failed to fetch data from the server')
		return
	}
	t := time.unix(resp.text.int())
	println(t.format()) // yyyy-mm-dd hh:mm
}

 

Found that out a while ago but thank you so much for answering. I forgot about this post.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×