Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OneWay trip doesn't need return date. #32

Open
zjplab opened this issue Dec 1, 2023 · 2 comments
Open

OneWay trip doesn't need return date. #32

zjplab opened this issue Dec 1, 2023 · 2 comments

Comments

@zjplab
Copy link

zjplab commented Dec 1, 2023

Hi thank you for this wonderful project! There are no other free and new flight search apis right now.

One improvement could be to remove the non-necessary returndate for oneway trip.

See here, if you comment out return date there will be an error.

package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/krisukox/google-flights-api/flights"
	"golang.org/x/text/currency"
	"golang.org/x/text/language"
)

func main() {
    session, err := flights.New()
    if err != nil {
        log.Fatal(err)
    }

    offers, priceRange, err := session.GetOffers(
        context.Background(),
        flights.Args{
            Date:       time.Now().AddDate(0, 0, 30),
            ReturnDate: time.Now().AddDate(0, 0, 37),
            SrcCities:  []string{"Madrid"},
            DstCities:  []string{"Estocolmo"},
            Options:    flights.Options{
                Travelers: flights.Travelers{Adults: 2},
                Currency:  currency.EUR,
                Stops:     flights.Stop1,
                Class:     flights.Economy,
                TripType:  flights.OneWay,
                Lang:      language.Spanish,
            },
        },
    )
    if err != nil {
        log.Fatal(err)
    }
    
    if priceRange != nil {
        fmt.Printf("High price %d\n", int(priceRange.High))
        fmt.Printf("Low price %d\n", int(priceRange.Low))
    }
    fmt.Println(offers)
}
@saadsarfraz
Copy link

has this been fixed? I'm facing the same issue that I can't do one way trips

@hu8813
Copy link

hu8813 commented Jul 7, 2024

how to check for OneWay, it gives, it shows 0
go run examples/example1/main.go
0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC
price 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants