ROOTPLOIT
Server: LiteSpeed
System: Linux in-mum-web1878.main-hosting.eu 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User: u435929562 (435929562)
PHP: 7.4.33
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/golang/1.22.0/src/go/build/constraint/vers_test.go
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package constraint

import (
	"fmt"
	"testing"
)

var tests = []struct {
	in  string
	out int
}{
	{"//go:build linux && go1.60", 60},
	{"//go:build ignore && go1.60", 60},
	{"//go:build ignore || go1.60", -1},
	{"//go:build go1.50 || (ignore && go1.60)", 50},
	{"// +build go1.60,linux", 60},
	{"// +build go1.60 linux", -1},
	{"//go:build go1.50 && !go1.60", 50},
	{"//go:build !go1.60", -1},
	{"//go:build linux && go1.50 || darwin && go1.60", 50},
	{"//go:build linux && go1.50 || !(!darwin || !go1.60)", 50},
}

func TestGoVersion(t *testing.T) {
	for _, tt := range tests {
		x, err := Parse(tt.in)
		if err != nil {
			t.Fatal(err)
		}
		v := GoVersion(x)
		want := ""
		if tt.out == 0 {
			want = "go1"
		} else if tt.out > 0 {
			want = fmt.Sprintf("go1.%d", tt.out)
		}
		if v != want {
			t.Errorf("GoVersion(%q) = %q, want %q, nil", tt.in, v, want)
		}
	}
}