# Path: pre_commit/languages/golang.py
# def guess_go_dir(remote_url: str) -> str:
#     if remote_url.endswith('.git'):
#         remote_url = remote_url[:-1 * len('.git')]
#     looks_like_url = (
#         not remote_url.startswith('file://') and
#         ('//' in remote_url or '@' in remote_url)
#     )
#     remote_url = remote_url.replace(':', '/')
#     if looks_like_url:
#         _, _, remote_url = remote_url.rpartition('//')
#         _, _, remote_url = remote_url.rpartition('@')
#         return remote_url
#     else:
#         return 'unknown_src_dir'


import pytest
from pre_commit.languages.golang import guess_go_dir
from __future__ import annotations




@pytest.mark.parametrize(
    ('url', 'expected'),
    (
        ('/im/a/path/on/disk', 'unknown_src_dir'),
        ('file:///im/a/path/on/disk', 'unknown_src_dir'),
        ('git@github.com:golang/lint', 'github.com/golang/lint'),
        ('git://github.com/golang/lint', 'github.com/golang/lint'),
        ('http://github.com/golang/lint', 'github.com/golang/lint'),
        ('https://github.com/golang/lint', 'github.com/golang/lint'),
        ('ssh://git@github.com/golang/lint', 'github.com/golang/lint'),
        ('git@github.com:golang/lint.git', 'github.com/golang/lint'),
    ),
)
def test_guess_go_dir(url, expected):

# Path: pre_commit/languages/golang.py
# def guess_go_dir(remote_url: str) -> str:
#     if remote_url.endswith('.git'):
#         remote_url = remote_url[:-1 * len('.git')]
#     looks_like_url = (
#         not remote_url.startswith('file://') and
#         ('//' in remote_url or '@' in remote_url)
#     )
#     remote_url = remote_url.replace(':', '/')
#     if looks_like_url:
#         _, _, remote_url = remote_url.rpartition('//')
#         _, _, remote_url = remote_url.rpartition('@')
#         return remote_url
#     else:
#         return 'unknown_src_dir'


# Path: tests/languages/golang_test.py
import pytest
from pre_commit.languages.golang import guess_go_dir

from __future__ import annotations




@pytest.mark.parametrize(
    ('url', 'expected'),
    (
        ('/im/a/path/on/disk', 'unknown_src_dir'),
        ('file:///im/a/path/on/disk', 'unknown_src_dir'),
        ('git@github.com:golang/lint', 'github.com/golang/lint'),
        ('git://github.com/golang/lint', 'github.com/golang/lint'),
        ('http://github.com/golang/lint', 'github.com/golang/lint'),
        ('https://github.com/golang/lint', 'github.com/golang/lint'),
        ('ssh://git@github.com/golang/lint', 'github.com/golang/lint'),
        ('git@github.com:golang/lint.git', 'github.com/golang/lint'),
    ),
)
def test_guess_go_dir(url, expected):

    assert guess_go_dir(url) == expected