modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/import6.go (about)

     1  // errorcheck
     2  
     3  // Copyright 2017 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // Verify that invalid imports are rejected by the compiler.
     8  // Does not compile.
     9  
    10  package main
    11  
    12  // Each of these pairs tests both `` vs "" strings
    13  // and also use of invalid characters spelled out as
    14  // escape sequences and written directly.
    15  // For example `"\x00"` tests import "\x00"
    16  // while "`\x00`" tests import `<actual-NUL-byte>`.
    17  import ""         // ERROR "import path"
    18  import ``         // ERROR "import path"
    19  import "\x00"     // ERROR "import path"
    20  import `\x00`     // ERROR "import path"
    21  import "\x7f"     // ERROR "import path"
    22  import `\x7f`     // ERROR "import path"
    23  import "a!"       // ERROR "import path"
    24  import `a!`       // ERROR "import path"
    25  import "a b"      // ERROR "import path"
    26  import `a b`      // ERROR "import path"
    27  import "a\\b"     // ERROR "import path"
    28  import `a\\b`     // ERROR "import path"
    29  import "\"`a`\""  // ERROR "import path"
    30  import `\"a\"`    // ERROR "import path"
    31  import "\x80\x80" // ERROR "import path"
    32  import `\x80\x80` // ERROR "import path"
    33  import "\xFFFD"   // ERROR "import path"
    34  import `\xFFFD`   // ERROR "import path"
    35  
    36  // Invalid local imports.
    37  import "/foo"  // ERROR "import path cannot be absolute path"
    38  import "c:/foo"  // ERROR "import path contains invalid character"